27class Error :
public std::runtime_error {
29 explicit Error(
const std::string &message) : std::runtime_error(message) {}
36 throw Error(message !=
nullptr ? message :
"unknown rustnn error");
119 static_cast<RustnnDataType>(data_type), shape.data(), shape.size(), &value_));
127 : value_(std::exchange(other.value_,
nullptr)) {}
130 if (
this != &other) {
132 value_ = std::exchange(other.value_,
nullptr);
146 bool readable,
bool writable) {
148 shape.data(), shape.size(), readable,
157 : value_(std::exchange(other.value_,
nullptr)) {}
160 if (
this != &other) {
162 value_ = std::exchange(other.value_,
nullptr);
182 if (
this != &other) {
184 value_ = std::exchange(other.value_,
nullptr);
202 MLGraph(
MLGraph &&other) noexcept : value_(std::exchange(other.value_,
nullptr)) {}
205 if (
this != &other) {
207 value_ = std::exchange(other.value_,
nullptr);
229 if (
this != &other) {
231 value_ = std::exchange(other.value_,
nullptr);
247 options.device_hint.has_value()
250 options.device_hint.has_value()
253 options.device_hint.has_value() ? options.device_hint->device_index : 0};
254 const TrtxOptions trtx = options.rustnn_options.has_value()
255 ? options.rustnn_options->trtx
260 trtx.fail_on_cache_miss,
267 options.device_hint.has_value(),
269 options.rustnn_options.has_value(),
281 if (
this != &other) {
283 value_ = std::exchange(other.value_,
nullptr);
296 template <
typename T>
298 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
300 data.size() *
sizeof(T)));
304 template <
typename T>
306 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
307 std::vector<T> data(element_count);
309 data.size() *
sizeof(T)));
315 const std::vector<std::pair<std::string, const MLTensor *>> &inputs,
316 const std::vector<std::pair<std::string, const MLTensor *>> &outputs) {
317 std::vector<RustnnNamedTensor> named_inputs;
318 named_inputs.reserve(inputs.size());
319 for (
const auto &[name, tensor] : inputs) {
320 named_inputs.push_back({name.c_str(), tensor !=
nullptr ? tensor->value_ :
nullptr});
322 std::vector<RustnnNamedTensor> named_outputs;
323 named_outputs.reserve(outputs.size());
324 for (
const auto &[name, tensor] : outputs) {
325 named_outputs.push_back({name.c_str(), tensor !=
nullptr ? tensor->value_ :
nullptr});
328 named_inputs.size(), named_outputs.data(),
329 named_outputs.size()));
337#define RUSTNN_ML_UNARY_METHOD(method, function) \
338 MLOperand method(const MLOperand &input) { \
339 RustnnOperand *output = nullptr; \
340 check(function(value_, input.value_, &output)); \
341 return MLOperand(output); \
344#define RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(method, function) \
345 RUSTNN_ML_UNARY_METHOD(method, function) \
346 MLOperand method(const MLOperand &input, \
347 const MLOperatorOptions &options) { \
348 RustnnOperand *output = nullptr; \
349 const RustnnOperatorOptions raw_options{options.label.c_str()}; \
350 check(function##_with_options(value_, input.value_, &raw_options, \
352 return MLOperand(output); \
355#define RUSTNN_ML_BINARY_METHOD(method, function) \
356 MLOperand method(const MLOperand &lhs, const MLOperand &rhs) { \
357 RustnnOperand *output = nullptr; \
358 check(function(value_, lhs.value_, rhs.value_, &output)); \
359 return MLOperand(output); \
362#define RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(method, function) \
363 RUSTNN_ML_BINARY_METHOD(method, function) \
364 MLOperand method(const MLOperand &lhs, const MLOperand &rhs, \
365 const MLOperatorOptions &options) { \
366 RustnnOperand *output = nullptr; \
367 const RustnnOperatorOptions raw_options{options.label.c_str()}; \
368 check(function##_with_options(value_, lhs.value_, rhs.value_, \
369 &raw_options, &output)); \
370 return MLOperand(output); \
373#define RUSTNN_ML_TERNARY_METHOD(method, function) \
374 MLOperand method(const MLOperand &first, const MLOperand &second, \
375 const MLOperand &third) { \
376 RustnnOperand *output = nullptr; \
377 check(function(value_, first.value_, second.value_, third.value_, \
379 return MLOperand(output); \
398 : value_(std::exchange(other.value_,
nullptr)) {}
401 if (
this != &other) {
403 value_ = std::exchange(other.value_,
nullptr);
416 template <
typename T>
418 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
421 data.size() *
sizeof(T), &output));
436 value_, operation,
input.value_, &raw_options, &output));
452 value_, operation, lhs.value_, rhs.value_, &raw_options, &output));
471 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(
logicalAnd,
473 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(
logicalOr,
475 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(
logicalXor,
495 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(
reciprocal,
498 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(
logicalNot,
504 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(
isInfinite,
589 const std::vector<std::uint32_t> &new_shape) {
592 new_shape.size(), &output));
597 const std::vector<std::uint32_t> &new_shape) {
600 new_shape.size(), &output));
605 const std::vector<std::uint32_t> &repetitions) {
608 repetitions.size(), &output));
613 const std::vector<std::uint32_t> &beginning_padding,
614 const std::vector<std::uint32_t> &ending_padding) {
617 value_,
input.value_, beginning_padding.data(), beginning_padding.size(),
618 ending_padding.data(), ending_padding.size(), &output));
623 const std::vector<std::uint32_t> &starts,
624 const std::vector<std::uint32_t> &sizes) {
627 starts.size(), sizes.data(), sizes.size(),
633 std::uint32_t axis) {
634 std::vector<const RustnnOperand *> raw_inputs;
635 raw_inputs.reserve(inputs.size());
637 raw_inputs.push_back(
input !=
nullptr ?
input->value_ :
nullptr);
649 value_,
input.value_, scale.value_,
650 zero_point !=
nullptr ? zero_point->value_ :
nullptr, &output));
658 value_,
input.value_, scale.value_,
659 zero_point !=
nullptr ? zero_point->value_ :
nullptr, &output));
664 const std::vector<std::uint32_t> &splits) {
665 std::vector<RustnnOperand *> raw_outputs(splits.size());
666 std::size_t outputs_len = 0;
668 raw_outputs.data(), raw_outputs.size(),
670 return wrapOperands(raw_outputs, outputs_len);
674 std::uint32_t num_splits) {
675 std::vector<RustnnOperand *> raw_outputs(num_splits);
676 std::size_t outputs_len = 0;
678 value_,
input.value_, num_splits, raw_outputs.data(), raw_outputs.size(),
680 return wrapOperands(raw_outputs, outputs_len);
685 std::uint32_t steps, std::uint32_t hidden_size) {
686 std::vector<RustnnOperand *> raw_outputs(1);
687 std::size_t outputs_len = 0;
689 value_,
input.value_, weight.value_, recurrent_weight.value_, steps,
690 hidden_size, raw_outputs.data(), raw_outputs.size(), &outputs_len));
691 return wrapOperands(raw_outputs, outputs_len);
696 const MLOperand &hidden_state, std::uint32_t hidden_size) {
699 value_,
input.value_, weight.value_, recurrent_weight.value_,
700 hidden_state.value_, hidden_size, &output));
706 std::uint32_t steps, std::uint32_t hidden_size) {
707 std::vector<RustnnOperand *> raw_outputs(2);
708 std::size_t outputs_len = 0;
710 value_,
input.value_, weight.value_, recurrent_weight.value_, steps,
711 hidden_size, raw_outputs.data(), raw_outputs.size(), &outputs_len));
712 return wrapOperands(raw_outputs, outputs_len);
715 std::vector<MLOperand>
718 const MLOperand &cell_state, std::uint32_t hidden_size) {
719 std::vector<RustnnOperand *> raw_outputs(2);
720 std::size_t outputs_len = 0;
722 value_,
input.value_, weight.value_, recurrent_weight.value_,
723 hidden_state.value_, cell_state.value_, hidden_size, raw_outputs.data(),
724 raw_outputs.size(), &outputs_len));
725 return wrapOperands(raw_outputs, outputs_len);
730 std::size_t rank = 0;
732 std::vector<std::uint64_t> dimensions(rank);
734 dimensions.size(), &rank));
746 const std::vector<std::pair<std::string, const MLOperand *>> &outputs)
const {
747 std::vector<RustnnNamedOperand> named;
748 named.reserve(outputs.size());
749 for (
const auto &[name, operand] : outputs) {
750 named.push_back({name.c_str(), operand !=
nullptr ? operand->value_ :
nullptr});
752 char *text =
nullptr;
754 std::string result(text);
760 MLGraph build(
const std::vector<std::pair<std::string, const MLOperand *>> &outputs) {
761 std::vector<RustnnNamedOperand> named;
762 named.reserve(outputs.size());
763 for (
const auto &[name, operand] : outputs) {
764 named.push_back({name.c_str(), operand !=
nullptr ? operand->value_ :
nullptr});
774 static std::vector<MLOperand>
775 wrapOperands(
const std::vector<RustnnOperand *> &raw_operands,
776 std::size_t length) {
777 std::vector<MLOperand> operands;
778 operands.reserve(length);
779 for (std::size_t index = 0; index < length; ++index) {
780 operands.push_back(
MLOperand(raw_operands[index]));
788#undef RUSTNN_ML_UNARY_METHOD
789#undef RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS
790#undef RUSTNN_ML_BINARY_METHOD
791#undef RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS
792#undef RUSTNN_ML_TERNARY_METHOD
Exception containing the C API's failure message.
Error(const std::string &message)
Owns a backend context for graph compilation, tensors and dispatch.
MLContext & operator=(const MLContext &)=delete
MLContext & operator=(MLContext &&other) noexcept
MLContext(MLContext &&other) noexcept
friend class MLGraphBuilder
std::vector< T > readTensor(const MLTensor &tensor, std::size_t element_count)
Copy a readable tensor into element_count values; T must match its storage.
void writeTensor(const MLTensor &tensor, const std::vector< T > &data)
Copy raw bytes from data into a writable tensor; T must match its storage.
MLTensor createTensor(const MLTensorDescriptor &descriptor)
Allocate a backend tensor with the descriptor's host access flags.
void dispatch(MLGraph &graph, const std::vector< std::pair< std::string, const MLTensor * > > &inputs, const std::vector< std::pair< std::string, const MLTensor * > > &outputs)
Execute a compiled graph with tensors bound by input and output name.
MLContext(const MLContext &)=delete
MLContext(const MLContextOptions &options={})
MLOperand hardSigmoid(const MLOperand &input)
MLOperand softsign(const MLOperand &input)
MLOperand maxPool2d(const MLOperand &input)
MLOperand averagePool2d(const MLOperand &input)
MLOperand gruCell(const MLOperand &input, const MLOperand &weight, const MLOperand &recurrent_weight, const MLOperand &hidden_state, std::uint32_t hidden_size)
std::vector< MLOperand > split(const MLOperand &input, const std::vector< std::uint32_t > &splits)
MLOperand squeeze(const MLOperand &input)
MLOperand greaterOrEqual(const MLOperand &lhs, const MLOperand &rhs)
MLOperand exp(const MLOperand &input)
MLOperand ceil(const MLOperand &input)
MLOperand convTranspose2d(const MLOperand &lhs, const MLOperand &rhs)
MLOperand binary(RustnnBinaryOperation operation, const MLOperand &lhs, const MLOperand &rhs, const MLOperatorOptions &options)
std::vector< MLOperand > lstmCell(const MLOperand &input, const MLOperand &weight, const MLOperand &recurrent_weight, const MLOperand &hidden_state, const MLOperand &cell_state, std::uint32_t hidden_size)
MLOperand softplus(const MLOperand &input)
MLOperand abs(const MLOperand &input)
MLOperand reshape(const MLOperand &input, const std::vector< std::uint32_t > &new_shape)
MLOperand layerNormalization(const MLOperand &input)
MLOperand isNaN(const MLOperand &input)
MLOperand argMin(const MLOperand &input, std::uint32_t axis)
MLOperand batchNormalization(const MLOperand &first, const MLOperand &second, const MLOperand &third)
MLOperand gather(const MLOperand &lhs, const MLOperand &rhs)
MLOperand reverse(const MLOperand &input)
MLGraphBuilder & operator=(MLGraphBuilder &&other) noexcept
MLOperand unary(RustnnUnaryOperation operation, const MLOperand &input)
MLOperand cos(const MLOperand &input)
MLOperand erf(const MLOperand &input)
MLOperand sqrt(const MLOperand &input)
MLOperand instanceNormalization(const MLOperand &input)
MLOperand argMax(const MLOperand &input, std::uint32_t axis)
MLOperand lesserOrEqual(const MLOperand &lhs, const MLOperand &rhs)
MLOperand notEqual(const MLOperand &lhs, const MLOperand &rhs)
MLOperandDataType dataType(const MLOperand &operand)
MLOperand sign(const MLOperand &input)
std::string webnnText(const std::vector< std::pair< std::string, const MLOperand * > > &outputs) const
Serialize the named outputs as rustnn WebNN graph text.
MLOperand prelu(const MLOperand &lhs, const MLOperand &rhs)
MLOperand reduceLogSum(const MLOperand &input)
MLOperand where(const MLOperand &first, const MLOperand &second, const MLOperand &third)
MLGraphBuilder(MLGraphBuilder &&other) noexcept
MLOperand isInfinite(const MLOperand &input)
MLOperand reduceSum(const MLOperand &input)
MLOperand dequantizeLinear(const MLOperand &input, const MLOperand &scale, const MLOperand *zero_point=nullptr)
MLOperand logicalOr(const MLOperand &lhs, const MLOperand &rhs)
MLOperand cast(const MLOperand &input, MLOperandDataType data_type)
MLOperand linear(const MLOperand &input)
MLOperand input(const std::string &name, const MLOperandDescriptor &descriptor)
Declare a named graph input with the supplied type and shape.
MLOperand leakyRelu(const MLOperand &input)
MLOperand logicalNot(const MLOperand &input)
MLOperand shape(const MLOperand &input)
MLOperand pad(const MLOperand &input, const std::vector< std::uint32_t > &beginning_padding, const std::vector< std::uint32_t > &ending_padding)
MLOperand gemm(const MLOperand &lhs, const MLOperand &rhs)
MLOperand identity(const MLOperand &input)
MLOperand concat(const std::vector< const MLOperand * > &inputs, std::uint32_t axis)
std::vector< MLOperand > gru(const MLOperand &input, const MLOperand &weight, const MLOperand &recurrent_weight, std::uint32_t steps, std::uint32_t hidden_size)
MLGraphBuilder(const MLGraphBuilder &)=delete
MLOperand roundEven(const MLOperand &input)
MLOperand sigmoid(const MLOperand &input)
MLOperand greater(const MLOperand &lhs, const MLOperand &rhs)
MLOperand sin(const MLOperand &input)
MLOperand reduceMax(const MLOperand &input)
MLOperand cumulativeSum(const MLOperand &input, std::uint32_t axis)
MLOperand slice(const MLOperand &input, const std::vector< std::uint32_t > &starts, const std::vector< std::uint32_t > &sizes)
MLOperand quantizeLinear(const MLOperand &input, const MLOperand &scale, const MLOperand *zero_point=nullptr)
MLOperand lesser(const MLOperand &lhs, const MLOperand &rhs)
MLOperand tan(const MLOperand &input)
MLOperand scatterElements(const MLOperand &first, const MLOperand &second, const MLOperand &third)
MLOperand unary(RustnnUnaryOperation operation, const MLOperand &input, const MLOperatorOptions &options)
MLOperand minimum(const MLOperand &lhs, const MLOperand &rhs)
MLOperand matmul(const MLOperand &lhs, const MLOperand &rhs)
MLGraphBuilder & operator=(const MLGraphBuilder &)=delete
MLOperand triangular(const MLOperand &input)
MLOperand softmax(const MLOperand &input, std::uint32_t axis)
MLOperand transpose(const MLOperand &input)
MLOperand add(const MLOperand &lhs, const MLOperand &rhs)
MLOperand constant(const MLOperandDescriptor &descriptor, const std::vector< T > &data)
Copy constant data into the graph; T must match the descriptor's storage.
MLOperand tile(const MLOperand &input, const std::vector< std::uint32_t > &repetitions)
MLOperand reduceMin(const MLOperand &input)
MLOperand l2Pool2d(const MLOperand &input)
MLOperand relu(const MLOperand &input)
MLOperand clamp(const MLOperand &input)
MLOperand logicalAnd(const MLOperand &lhs, const MLOperand &rhs)
std::vector< std::uint64_t > operandShape(const MLOperand &operand)
Return an operand's inferred dimensions.
MLOperand divide(const MLOperand &lhs, const MLOperand &rhs)
MLOperand hardSwish(const MLOperand &input)
MLOperand conv2d(const MLOperand &lhs, const MLOperand &rhs)
MLOperand binary(RustnnBinaryOperation operation, const MLOperand &lhs, const MLOperand &rhs)
MLOperand tanh(const MLOperand &input)
MLOperand multiply(const MLOperand &lhs, const MLOperand &rhs)
MLOperand maximum(const MLOperand &lhs, const MLOperand &rhs)
MLOperand resample2d(const MLOperand &input)
MLOperand reduceLogSumExp(const MLOperand &input)
MLOperand equal(const MLOperand &lhs, const MLOperand &rhs)
MLOperand reduceL1(const MLOperand &input)
MLOperand gatherND(const MLOperand &lhs, const MLOperand &rhs)
MLOperand log(const MLOperand &input)
MLOperand elu(const MLOperand &input)
MLOperand scatterND(const MLOperand &first, const MLOperand &second, const MLOperand &third)
MLGraphBuilder(MLContext &context)
MLOperand negate(const MLOperand &input)
MLOperand power(const MLOperand &lhs, const MLOperand &rhs)
MLOperand reduceProduct(const MLOperand &input)
MLOperand logicalXor(const MLOperand &lhs, const MLOperand &rhs)
MLOperand subtract(const MLOperand &lhs, const MLOperand &rhs)
MLOperand gatherElements(const MLOperand &lhs, const MLOperand &rhs)
MLOperand reduceSumSquare(const MLOperand &input)
MLOperand reciprocal(const MLOperand &input)
MLOperand reduceMean(const MLOperand &input)
std::vector< MLOperand > split(const MLOperand &input, std::uint32_t num_splits)
MLOperand floor(const MLOperand &input)
MLGraph build(const std::vector< std::pair< std::string, const MLOperand * > > &outputs)
Compile named outputs and consume this builder; the context must outlive the graph.
MLOperand unsqueeze(const MLOperand &input)
MLOperand expand(const MLOperand &input, const std::vector< std::uint32_t > &new_shape)
MLOperand reduceL2(const MLOperand &input)
MLOperand gelu(const MLOperand &input)
std::vector< MLOperand > lstm(const MLOperand &input, const MLOperand &weight, const MLOperand &recurrent_weight, std::uint32_t steps, std::uint32_t hidden_size)
Owns a compiled graph. Its originating context must outlive it.
MLGraph(const MLGraph &)=delete
MLGraph & operator=(const MLGraph &)=delete
friend class MLGraphBuilder
MLGraph & operator=(MLGraph &&other) noexcept
MLGraph(MLGraph &&other) noexcept
Owns an operand's element type and shape descriptor.
MLOperandDescriptor(const MLOperandDescriptor &)=delete
MLOperandDescriptor & operator=(MLOperandDescriptor &&other) noexcept
MLOperandDescriptor(MLOperandDescriptor &&other) noexcept
MLOperandDescriptor & operator=(const MLOperandDescriptor &)=delete
friend class MLGraphBuilder
MLOperandDescriptor(MLOperandDataType data_type, const std::vector< std::uint64_t > &shape)
Owns an operand handle belonging to a graph builder.
MLOperand & operator=(const MLOperand &)=delete
friend class MLGraphBuilder
MLOperand & operator=(MLOperand &&other) noexcept
MLOperand(MLOperand &&other) noexcept
MLOperand(const MLOperand &)=delete
Owns a tensor descriptor with host read and write permissions.
MLTensorDescriptor(const MLTensorDescriptor &)=delete
MLTensorDescriptor(MLOperandDataType data_type, const std::vector< std::uint64_t > &shape, bool readable, bool writable)
MLTensorDescriptor & operator=(const MLTensorDescriptor &)=delete
MLTensorDescriptor & operator=(MLTensorDescriptor &&other) noexcept
MLTensorDescriptor(MLTensorDescriptor &&other) noexcept
Owns a backend tensor. Its originating context must outlive it.
MLTensor(MLTensor &&other) noexcept
MLTensor(const MLTensor &)=delete
MLTensor & operator=(const MLTensor &)=delete
MLTensor & operator=(MLTensor &&other) noexcept
void check(RustnnStatus status)
Throw Error if a C API call returned a failing status.
MLOperandDataType
Element type, including packed signed and unsigned 4-bit integers.
void initializeLogger()
Initialize rustnn's logger using the environment configuration.
MLPowerPreference
Power preference used for automatic backend selection.
Backend
Backend hint; Automatic delegates selection to rustnn.
DeviceType
Kind of device used to execute a graph.
enum RustnnStatus rustnn_graph_builder_erf(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the erf operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gelu(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the gelu operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_elu(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the elu operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_round_even(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the round even operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_lesser_or_equal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the lesser or equal operation using [MLGraphBuilder].
enum RustnnStatus rustnn_context_dispatch(struct RustnnContext *context, struct RustnnGraph *graph, const struct RustnnNamedTensor *inputs, uintptr_t inputs_len, const struct RustnnNamedTensor *outputs, uintptr_t outputs_len)
Run an [MLGraph] through [MLContext] with named input and output tensors.
void rustnn_operand_destroy(struct RustnnOperand *operand)
Release an [MLOperand] handle.
enum RustnnStatus rustnn_graph_builder_constant(struct RustnnGraphBuilder *builder, const struct RustnnOperandDescriptor *descriptor, const void *data, uintptr_t data_len, struct RustnnOperand **output)
Create a constant [MLOperand] from descriptor and bytes on [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_is_infinite(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the is infinite operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_concat(struct RustnnGraphBuilder *builder, const struct RustnnOperand *const *inputs, uintptr_t inputs_len, uint32_t axis, struct RustnnOperand **output)
Apply the concat operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_add(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the add operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_sqrt(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the sqrt operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_max_pool2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the max pool2d operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_operand_data_type(struct RustnnGraphBuilder *builder, const struct RustnnOperand *operand, enum RustnnDataType *data_type)
Read an [MLOperand] data type from [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_l1(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce l1 operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_softsign(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the softsign operation using [MLGraphBuilder].
const char * rustnn_last_error_message(void)
Return the last C API error message for this thread.
enum RustnnStatus rustnn_graph_builder_matmul(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the matmul operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_binary(struct RustnnGraphBuilder *builder, enum RustnnBinaryOperation operation, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply a selected binary operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_log(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the log operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_sin(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the sin operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_layer_normalization(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the layer normalization operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_negate(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the negate operation using [MLGraphBuilder].
void rustnn_graph_destroy(struct RustnnGraph *graph)
Release an [MLGraph] handle.
void rustnn_operand_descriptor_destroy(struct RustnnOperandDescriptor *descriptor)
Release an [MLOperandDescriptor] handle.
enum RustnnStatus rustnn_graph_builder_floor(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the floor operation using [MLGraphBuilder].
struct RustnnOperandDescriptor RustnnOperandDescriptor
Opaque handle wrapping [MLOperandDescriptor].
enum RustnnStatus rustnn_graph_builder_gru_cell(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *weight, const struct RustnnOperand *recurrent_weight, const struct RustnnOperand *hidden_state, uint32_t hidden_size, struct RustnnOperand **output)
Apply the gru cell operation using [MLGraphBuilder].
RustnnBinaryOperation
Implementation detail of the C++ API.
RustnnDataType
C representation of [MLOperandDataType].
@ RustnnDataType_Bfloat16
@ RustnnDataType_Float8e4m3
enum RustnnStatus rustnn_graph_builder_batch_normalization(struct RustnnGraphBuilder *builder, const struct RustnnOperand *first, const struct RustnnOperand *second, const struct RustnnOperand *third, struct RustnnOperand **output)
Apply the batch normalization operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_shape(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the shape operation using [MLGraphBuilder].
struct RustnnOperand RustnnOperand
Opaque handle wrapping [MLOperand].
struct RustnnGraphBuilder RustnnGraphBuilder
Opaque handle wrapping [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_unary(struct RustnnGraphBuilder *builder, enum RustnnUnaryOperation operation, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply a selected unary operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_is_nan(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the is nan operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_power(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the power operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_minimum(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the minimum operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_sign(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the sign operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_webnn_text(const struct RustnnGraphBuilder *builder, const struct RustnnNamedOperand *outputs, uintptr_t outputs_len, char **text)
Serialize [MLGraphBuilder] output operands as rustnn WebNN text.
RustnnBackend
Backend hint for [MLContextOptions], wrapping [Backend].
@ RustnnBackend_Automatic
Select a backend automatically.
@ RustnnBackend_Litert
Use LiteRT.
@ RustnnBackend_Cann
Use CANN.
@ RustnnBackend_Onnx
Use ONNX Runtime.
@ RustnnBackend_Coreml
Use CoreML.
@ RustnnBackend_Trtx
Use TensorRT-RTX.
enum RustnnStatus rustnn_graph_builder_ceil(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the ceil operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_cos(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the cos operation using [MLGraphBuilder].
struct RustnnTensor RustnnTensor
Opaque handle wrapping [MLTensor].
enum RustnnStatus rustnn_graph_builder_squeeze(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the squeeze operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_conv_transpose2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the conv transpose2d operation using [MLGraphBuilder].
enum RustnnStatus rustnn_operand_descriptor_create(enum RustnnDataType data_type, const uint64_t *shape, uintptr_t shape_len, struct RustnnOperandDescriptor **output)
Allocate an [MLOperandDescriptor] from a data type and shape.
enum RustnnStatus rustnn_graph_builder_softmax(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, uint32_t axis, struct RustnnOperand **output)
Apply the softmax operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_build(struct RustnnGraphBuilder **builder, const struct RustnnNamedOperand *outputs, uintptr_t outputs_len, struct RustnnGraph **graph)
Compile a runtime-backed [MLGraphBuilder] into an [MLGraph] and consume it, setting builder to null.
enum RustnnStatus rustnn_graph_builder_clamp(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the clamp operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_split_equal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, uint32_t num_splits, struct RustnnOperand **outputs, uintptr_t outputs_capacity, uintptr_t *outputs_len)
Apply the split equal operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_multiply(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the multiply operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_hard_sigmoid(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the hard sigmoid operation using [MLGraphBuilder].
struct RustnnContext RustnnContext
Opaque handle wrapping [MLContext].
enum RustnnStatus rustnn_graph_builder_subtract(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the subtract operation using [MLGraphBuilder].
void rustnn_tensor_destroy(struct RustnnTensor *tensor)
Release an [MLTensor] handle.
enum RustnnStatus rustnn_graph_builder_expand(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *new_shape, uintptr_t new_shape_len, struct RustnnOperand **output)
Apply the expand operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_conv2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the conv2d operation using [MLGraphBuilder].
RustnnDeviceType
C representation of [DeviceType] for a [BackendDevice] hint.
@ RustnnDeviceType_Npu
NPU device.
@ RustnnDeviceType_Gpu
GPU device.
@ RustnnDeviceType_Cpu
CPU device.
enum RustnnStatus rustnn_graph_builder_sigmoid(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the sigmoid operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_transpose(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the transpose operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_softplus(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the softplus operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_mean(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce mean operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gather_elements(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the gather elements operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_quantize_linear(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *scale, const struct RustnnOperand *zero_point, struct RustnnOperand **output)
Apply the quantize linear operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_leaky_relu(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the leaky relu operation using [MLGraphBuilder].
enum RustnnStatus rustnn_context_create(const struct RustnnContextOptions *options, struct RustnnContext **output)
Create an [MLContext].
enum RustnnStatus rustnn_graph_builder_reduce_max(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce max operation using [MLGraphBuilder].
struct RustnnTensorDescriptor RustnnTensorDescriptor
Opaque handle wrapping [MLTensorDescriptor].
enum RustnnStatus rustnn_graph_builder_reshape(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *new_shape, uintptr_t new_shape_len, struct RustnnOperand **output)
Apply the reshape operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_min(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce min operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_slice(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *starts, uintptr_t starts_len, const uint32_t *sizes, uintptr_t sizes_len, struct RustnnOperand **output)
Apply the slice operation using [MLGraphBuilder].
void rustnn_tensor_descriptor_destroy(struct RustnnTensorDescriptor *descriptor)
Release an [MLTensorDescriptor] handle.
enum RustnnStatus rustnn_graph_builder_scatter_elements(struct RustnnGraphBuilder *builder, const struct RustnnOperand *first, const struct RustnnOperand *second, const struct RustnnOperand *third, struct RustnnOperand **output)
Apply the scatter elements operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_unary_with_options(struct RustnnGraphBuilder *builder, enum RustnnUnaryOperation operation, const struct RustnnOperand *input, const struct RustnnOperatorOptions *options, struct RustnnOperand **output)
Implementation detail of the C++ API.
enum RustnnStatus rustnn_graph_builder_reduce_log_sum(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce log sum operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_divide(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the divide operation using [MLGraphBuilder].
enum RustnnStatus rustnn_tensor_descriptor_create(enum RustnnDataType data_type, const uint64_t *shape, uintptr_t shape_len, bool readable, bool writable, struct RustnnTensorDescriptor **output)
Allocate an [MLTensorDescriptor].
enum RustnnStatus rustnn_graph_builder_input(struct RustnnGraphBuilder *builder, const char *name, const struct RustnnOperandDescriptor *descriptor, struct RustnnOperand **output)
Declare a named input [MLOperand] on [MLGraphBuilder].
RustnnUnaryOperation
Implementation detail of the C++ API.
enum RustnnStatus rustnn_graph_builder_reciprocal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reciprocal operation using [MLGraphBuilder].
void rustnn_string_destroy(char *value)
Release a string returned by this C API.
enum RustnnStatus rustnn_graph_builder_relu(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the relu operation using [MLGraphBuilder].
enum RustnnStatus rustnn_context_create_tensor(struct RustnnContext *context, const struct RustnnTensorDescriptor *descriptor, struct RustnnTensor **output)
Allocate an [MLTensor] from an [MLTensorDescriptor].
struct RustnnGraph RustnnGraph
Opaque handle wrapping [MLGraph].
enum RustnnStatus rustnn_graph_builder_reduce_sum(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce sum operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_create_uncompiled(struct RustnnGraphBuilder **output)
Create an uncompiled [MLGraphBuilder] for graph construction and serialization.
void rustnn_init_logger(void)
Install a tracing_subscriber global subscriber if none is installed yet.
enum RustnnStatus rustnn_graph_builder_identity(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the identity operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_tan(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the tan operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_arg_max(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, uint32_t axis, struct RustnnOperand **output)
Apply the arg max operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_logical_or(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the logical or operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_binary_with_options(struct RustnnGraphBuilder *builder, enum RustnnBinaryOperation operation, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, const struct RustnnOperatorOptions *options, struct RustnnOperand **output)
Implementation detail of the C++ API.
RustnnPowerPreference
C representation of [MLPowerPreference].
@ RustnnPowerPreference_HighPerformance
Prefer high performance.
@ RustnnPowerPreference_LowPower
Prefer low power.
@ RustnnPowerPreference_Default
Use the default power preference.
enum RustnnStatus rustnn_graph_builder_logical_not(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the logical not operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gather_nd(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the gather nd operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_triangular(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the triangular operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_l2(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce l2 operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_l2_pool2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the l2 pool2d operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_resample2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the resample2d operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_prelu(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the prelu operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_pad(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *beginning_padding, uintptr_t beginning_padding_len, const uint32_t *ending_padding, uintptr_t ending_padding_len, struct RustnnOperand **output)
Apply the pad operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gru(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *weight, const struct RustnnOperand *recurrent_weight, uint32_t steps, uint32_t hidden_size, struct RustnnOperand **outputs, uintptr_t outputs_capacity, uintptr_t *outputs_len)
Apply the gru operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_hard_swish(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the hard swish operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_split(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *splits, uintptr_t splits_len, struct RustnnOperand **outputs, uintptr_t outputs_capacity, uintptr_t *outputs_len)
Apply the split operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reverse(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reverse operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_lstm(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *weight, const struct RustnnOperand *recurrent_weight, uint32_t steps, uint32_t hidden_size, struct RustnnOperand **outputs, uintptr_t outputs_capacity, uintptr_t *outputs_len)
Apply the lstm operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_not_equal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the not equal operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gemm(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the gemm operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_logical_and(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the logical and operation using [MLGraphBuilder].
RustnnStatus
Result of a C API call.
@ RustnnStatus_Success
The call completed successfully.
enum RustnnStatus rustnn_graph_builder_tile(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const uint32_t *repetitions, uintptr_t repetitions_len, struct RustnnOperand **output)
Apply the tile operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_arg_min(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, uint32_t axis, struct RustnnOperand **output)
Apply the arg min operation using [MLGraphBuilder].
enum RustnnStatus rustnn_context_read_tensor(struct RustnnContext *context, const struct RustnnTensor *tensor, void *data, uintptr_t data_len)
Copy bytes from an [MLTensor] through [MLContext].
enum RustnnStatus rustnn_graph_builder_abs(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the abs operation using [MLGraphBuilder].
void rustnn_graph_builder_destroy(struct RustnnGraphBuilder *builder)
Release an [MLGraphBuilder] handle.
enum RustnnStatus rustnn_graph_builder_instance_normalization(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the instance normalization operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_scatter_nd(struct RustnnGraphBuilder *builder, const struct RustnnOperand *first, const struct RustnnOperand *second, const struct RustnnOperand *third, struct RustnnOperand **output)
Apply the scatter nd operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_cumulative_sum(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, uint32_t axis, struct RustnnOperand **output)
Apply the cumulative sum operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_greater_or_equal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the greater or equal operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_maximum(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the maximum operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_greater(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the greater operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_unsqueeze(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the unsqueeze operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_create(struct RustnnContext *context, struct RustnnGraphBuilder **output)
Create a runtime-backed [MLGraphBuilder] that exclusively borrows context.
enum RustnnStatus rustnn_context_write_tensor(struct RustnnContext *context, const struct RustnnTensor *tensor, const void *data, uintptr_t data_len)
Copy bytes into an [MLTensor] through [MLContext].
enum RustnnStatus rustnn_graph_builder_lstm_cell(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *weight, const struct RustnnOperand *recurrent_weight, const struct RustnnOperand *hidden_state, const struct RustnnOperand *cell_state, uint32_t hidden_size, struct RustnnOperand **outputs, uintptr_t outputs_capacity, uintptr_t *outputs_len)
Apply the lstm cell operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_cast(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, enum RustnnDataType data_type, struct RustnnOperand **output)
Apply the cast operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_logical_xor(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the logical xor operation using [MLGraphBuilder].
void rustnn_context_destroy(struct RustnnContext *context)
Release an [MLContext] handle.
enum RustnnStatus rustnn_graph_builder_reduce_product(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce product operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_equal(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the equal operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_sum_square(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce sum square operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_operand_shape(struct RustnnGraphBuilder *builder, const struct RustnnOperand *operand, uint64_t *dimensions, uintptr_t dimensions_capacity, uintptr_t *dimensions_len)
Copy an [MLOperand] shape from [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_dequantize_linear(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, const struct RustnnOperand *scale, const struct RustnnOperand *zero_point, struct RustnnOperand **output)
Apply the dequantize linear operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_where(struct RustnnGraphBuilder *builder, const struct RustnnOperand *first, const struct RustnnOperand *second, const struct RustnnOperand *third, struct RustnnOperand **output)
Apply the where operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_tanh(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the tanh operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_gather(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the gather operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_linear(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the linear operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_lesser(struct RustnnGraphBuilder *builder, const struct RustnnOperand *lhs, const struct RustnnOperand *rhs, struct RustnnOperand **output)
Apply the lesser operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_reduce_log_sum_exp(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the reduce log sum exp operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_exp(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the exp operation using [MLGraphBuilder].
enum RustnnStatus rustnn_graph_builder_average_pool2d(struct RustnnGraphBuilder *builder, const struct RustnnOperand *input, struct RustnnOperand **output)
Apply the average pool2d operation using [MLGraphBuilder].
C representation of [BackendDevice].
C representation of [MLContextOptions].
C representation of [MLOperatorOptions] shared by the operations exposed by this ABI.
C representation of [RustNNOptions].
Explicit backend and device hint for context creation.
Backend selection and runtime configuration for MLContext.
std::optional< RustNNOptions > rustnn_options
std::optional< BackendDevice > device_hint
MLPowerPreference power_preference
Optional operator label used in diagnostics.
rustnn-specific backend configuration.
TensorRT-RTX engine caching and execution options.