include/tenzr/runtime/pjrt_profiler.h
Namespaces
Classes
|
Name |
| class |
tenzr::PjrtProfiler Drives the optional PJRT profiler extension and captures a serialized XPlane profile. |
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_RUNTIME_PJRT_PROFILER_H_
#define TENZR_RUNTIME_PJRT_PROFILER_H_
#include <xla/backends/profiler/plugin/profiler_c_api.h>
#include <xla/pjrt/c/pjrt_c_api.h>
#include <xla/pjrt/c/pjrt_c_api_profiler_extension.h>
#include <cstdint>
#include <string>
#include <vector>
namespace tenzr {
class PjrtProfiler {
public:
PjrtProfiler();
~PjrtProfiler();
PjrtProfiler(const PjrtProfiler&) = delete;
PjrtProfiler& operator=(const PjrtProfiler&) = delete;
[[nodiscard]] bool Supported() const;
bool Start();
bool Stop();
[[nodiscard]] std::vector<uint8_t> CollectData() const;
bool Dump(const std::string& path) const;
private:
const PLUGIN_Profiler_Api* api_{nullptr};
PLUGIN_Profiler* profiler_{nullptr};
bool started_{false};
};
} // namespace tenzr
#endif // TENZR_RUNTIME_PJRT_PROFILER_H_