include/tenzr/sharding/shardy.h
Namespaces
Classes
Source code
// Copyright 2026 The Tenzr Project Authors
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT 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 TENZR_SHARDING_SHARDY_H_
#define TENZR_SHARDING_SHARDY_H_
#include <string>
#include <string_view>
#include <vector>
#include "tenzr/common/export.h"
#include "tenzr/frontend/shape.h"
#include "tenzr/sharding/mesh.h"
#include "tenzr/sharding/named_sharding.h"
#include "tenzr/sharding/partition_spec.h"
namespace tenzr::sharding {
struct TENZR_API ShardingAnalysis {
std::string mesh_decl;
std::string shardy_attr;
std::string gspmd_attr;
std::string shardy_constraint_op;
bool is_replicated{false};
bool is_unconstrained{false};
[[nodiscard]] std::string FormatReport() const;
};
[[nodiscard]] TENZR_API ShardingAnalysis AnalyzeSharding(const NamedSharding& sharding, const Shape& tensor_shape, std::string_view var_name = "%0",
std::string_view tensor_type = "tensor<f32>");
[[nodiscard]] TENZR_API std::string FormatShardyModuleHeader(const Mesh& mesh, std::string_view func_name, const std::vector<NamedSharding>& arg_shardings,
const std::vector<Shape>& arg_shapes, std::string_view mesh_sym = "mesh");
} // namespace tenzr::sharding
#endif // TENZR_SHARDING_SHARDY_H_