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");
117 static_cast<RustnnDataType>(data_type), shape.data(), shape.size(), &value_));
125 : value_(std::exchange(other.value_,
nullptr)) {}
128 if (
this != &other) {
130 value_ = std::exchange(other.value_,
nullptr);
144 bool readable,
bool writable) {
146 shape.data(), shape.size(), readable,
155 : value_(std::exchange(other.value_,
nullptr)) {}
158 if (
this != &other) {
160 value_ = std::exchange(other.value_,
nullptr);
180 if (
this != &other) {
182 value_ = std::exchange(other.value_,
nullptr);
200 MLGraph(
MLGraph &&other) noexcept : value_(std::exchange(other.value_,
nullptr)) {}
203 if (
this != &other) {
205 value_ = std::exchange(other.value_,
nullptr);
227 if (
this != &other) {
229 value_ = std::exchange(other.value_,
nullptr);
245 options.device_hint.has_value()
248 options.device_hint.has_value()
251 options.device_hint.has_value() ? options.device_hint->device_index : 0};
252 const TrtxOptions trtx = options.rustnn_options.has_value()
253 ? options.rustnn_options->trtx
265 options.device_hint.has_value(),
267 options.rustnn_options.has_value(),
279 if (
this != &other) {
281 value_ = std::exchange(other.value_,
nullptr);
294 template <
typename T>
296 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
298 data.size() *
sizeof(T)));
302 template <
typename T>
304 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
305 std::vector<T> data(element_count);
307 data.size() *
sizeof(T)));
313 const std::vector<std::pair<std::string, const MLTensor *>> &inputs,
314 const std::vector<std::pair<std::string, const MLTensor *>> &outputs) {
315 std::vector<RustnnNamedTensor> named_inputs;
316 named_inputs.reserve(inputs.size());
317 for (
const auto &[name, tensor] : inputs) {
318 named_inputs.push_back({name.c_str(), tensor !=
nullptr ? tensor->value_ :
nullptr});
320 std::vector<RustnnNamedTensor> named_outputs;
321 named_outputs.reserve(outputs.size());
322 for (
const auto &[name, tensor] : outputs) {
323 named_outputs.push_back({name.c_str(), tensor !=
nullptr ? tensor->value_ :
nullptr});
326 named_inputs.size(), named_outputs.data(),
327 named_outputs.size()));
335#define RUSTNN_ML_UNARY_METHOD(method, function) \
336 MLOperand method(const MLOperand &input) { \
337 RustnnOperand *output = nullptr; \
338 check(function(value_, input.value_, &output)); \
339 return MLOperand(output); \
342#define RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(method, function) \
343 RUSTNN_ML_UNARY_METHOD(method, function) \
344 MLOperand method(const MLOperand &input, \
345 const MLOperatorOptions &options) { \
346 RustnnOperand *output = nullptr; \
347 const RustnnOperatorOptions raw_options{options.label.c_str()}; \
348 check(function##_with_options(value_, input.value_, &raw_options, \
350 return MLOperand(output); \
353#define RUSTNN_ML_BINARY_METHOD(method, function) \
354 MLOperand method(const MLOperand &lhs, const MLOperand &rhs) { \
355 RustnnOperand *output = nullptr; \
356 check(function(value_, lhs.value_, rhs.value_, &output)); \
357 return MLOperand(output); \
360#define RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(method, function) \
361 RUSTNN_ML_BINARY_METHOD(method, function) \
362 MLOperand method(const MLOperand &lhs, const MLOperand &rhs, \
363 const MLOperatorOptions &options) { \
364 RustnnOperand *output = nullptr; \
365 const RustnnOperatorOptions raw_options{options.label.c_str()}; \
366 check(function##_with_options(value_, lhs.value_, rhs.value_, \
367 &raw_options, &output)); \
368 return MLOperand(output); \
371#define RUSTNN_ML_TERNARY_METHOD(method, function) \
372 MLOperand method(const MLOperand &first, const MLOperand &second, \
373 const MLOperand &third) { \
374 RustnnOperand *output = nullptr; \
375 check(function(value_, first.value_, second.value_, third.value_, \
377 return MLOperand(output); \
396 : value_(std::exchange(other.value_,
nullptr)) {}
399 if (
this != &other) {
401 value_ = std::exchange(other.value_,
nullptr);
414 template <
typename T>
416 static_assert(std::is_trivially_copyable_v<T>,
"tensor elements must be plain data");
419 data.size() *
sizeof(T), &output));
434 value_, operation, input.value_, &raw_options, &output));
450 value_, operation, lhs.value_, rhs.value_, &raw_options, &output));
463 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(greaterOrEqual,
466 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(lesserOrEqual,
469 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(logicalAnd,
471 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(logicalOr,
473 RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS(logicalXor,
493 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(reciprocal,
496 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(logicalNot,
502 RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS(isInfinite,
512 RUSTNN_ML_UNARY_METHOD(instanceNormalization,
514 RUSTNN_ML_UNARY_METHOD(layerNormalization,
530 RUSTNN_ML_UNARY_METHOD(reduceLogSumExp,
532 RUSTNN_ML_UNARY_METHOD(reduceSumSquare,
540 RUSTNN_ML_BINARY_METHOD(convTranspose2d,
543 RUSTNN_ML_BINARY_METHOD(gatherElements,
548 RUSTNN_ML_TERNARY_METHOD(batchNormalization,
551 RUSTNN_ML_TERNARY_METHOD(scatterElements,
587 const std::vector<std::uint32_t> &new_shape) {
590 new_shape.size(), &output));
595 const std::vector<std::uint32_t> &new_shape) {
598 new_shape.size(), &output));
603 const std::vector<std::uint32_t> &repetitions) {
606 repetitions.size(), &output));
611 const std::vector<std::uint32_t> &beginning_padding,
612 const std::vector<std::uint32_t> &ending_padding) {
615 value_, input.value_, beginning_padding.data(), beginning_padding.size(),
616 ending_padding.data(), ending_padding.size(), &output));
621 const std::vector<std::uint32_t> &starts,
622 const std::vector<std::uint32_t> &sizes) {
625 starts.size(), sizes.data(), sizes.size(),
631 std::uint32_t axis) {
632 std::vector<const RustnnOperand *> raw_inputs;
633 raw_inputs.reserve(inputs.size());
635 raw_inputs.push_back(input !=
nullptr ? input->value_ :
nullptr);
647 value_, input.value_, scale.value_,
648 zero_point !=
nullptr ? zero_point->value_ :
nullptr, &output));
656 value_, input.value_, scale.value_,
657 zero_point !=
nullptr ? zero_point->value_ :
nullptr, &output));
662 const std::vector<std::uint32_t> &splits) {
663 std::vector<RustnnOperand *> raw_outputs(splits.size());
664 std::size_t outputs_len = 0;
666 raw_outputs.data(), raw_outputs.size(),
668 return wrapOperands(raw_outputs, outputs_len);
672 std::uint32_t num_splits) {
673 std::vector<RustnnOperand *> raw_outputs(num_splits);
674 std::size_t outputs_len = 0;
676 value_, input.value_, num_splits, raw_outputs.data(), raw_outputs.size(),
678 return wrapOperands(raw_outputs, outputs_len);
683 std::uint32_t steps, std::uint32_t hidden_size) {
684 std::vector<RustnnOperand *> raw_outputs(1);
685 std::size_t outputs_len = 0;
687 value_, input.value_, weight.value_, recurrent_weight.value_, steps,
688 hidden_size, raw_outputs.data(), raw_outputs.size(), &outputs_len));
689 return wrapOperands(raw_outputs, outputs_len);
694 const MLOperand &hidden_state, std::uint32_t hidden_size) {
697 value_, input.value_, weight.value_, recurrent_weight.value_,
698 hidden_state.value_, hidden_size, &output));
704 std::uint32_t steps, std::uint32_t hidden_size) {
705 std::vector<RustnnOperand *> raw_outputs(2);
706 std::size_t outputs_len = 0;
708 value_, input.value_, weight.value_, recurrent_weight.value_, steps,
709 hidden_size, raw_outputs.data(), raw_outputs.size(), &outputs_len));
710 return wrapOperands(raw_outputs, outputs_len);
713 std::vector<MLOperand>
716 const MLOperand &cell_state, std::uint32_t hidden_size) {
717 std::vector<RustnnOperand *> raw_outputs(2);
718 std::size_t outputs_len = 0;
720 value_, input.value_, weight.value_, recurrent_weight.value_,
721 hidden_state.value_, cell_state.value_, hidden_size, raw_outputs.data(),
722 raw_outputs.size(), &outputs_len));
723 return wrapOperands(raw_outputs, outputs_len);
728 std::size_t rank = 0;
730 std::vector<std::uint64_t> dimensions(rank);
732 dimensions.size(), &rank));
744 const std::vector<std::pair<std::string, const MLOperand *>> &outputs)
const {
745 std::vector<RustnnNamedOperand> named;
746 named.reserve(outputs.size());
747 for (
const auto &[name, operand] : outputs) {
748 named.push_back({name.c_str(), operand !=
nullptr ? operand->value_ :
nullptr});
750 char *text =
nullptr;
752 std::string result(text);
758 MLGraph build(
const std::vector<std::pair<std::string, const MLOperand *>> &outputs) {
759 std::vector<RustnnNamedOperand> named;
760 named.reserve(outputs.size());
761 for (
const auto &[name, operand] : outputs) {
762 named.push_back({name.c_str(), operand !=
nullptr ? operand->value_ :
nullptr});
772 static std::vector<MLOperand>
773 wrapOperands(
const std::vector<RustnnOperand *> &raw_operands,
774 std::size_t length) {
775 std::vector<MLOperand> operands;
776 operands.reserve(length);
777 for (std::size_t index = 0; index < length; ++index) {
778 operands.push_back(
MLOperand(raw_operands[index]));
786#undef RUSTNN_ML_UNARY_METHOD
787#undef RUSTNN_ML_UNARY_METHOD_WITH_OPTIONS
788#undef RUSTNN_ML_BINARY_METHOD
789#undef RUSTNN_ML_BINARY_METHOD_WITH_OPTIONS
790#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
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={})
Records and validates graph operations.
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 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 reshape(const MLOperand &input, const std::vector< std::uint32_t > &new_shape)
MLGraphBuilder & operator=(MLGraphBuilder &&other) noexcept
MLOperand unary(RustnnUnaryOperation operation, const MLOperand &input)
MLOperand argMax(const MLOperand &input, std::uint32_t axis)
MLOperandDataType dataType(const MLOperand &operand)
std::string webnnText(const std::vector< std::pair< std::string, const MLOperand * > > &outputs) const
Serialize the named outputs as rustnn WebNN graph text.
MLGraphBuilder(MLGraphBuilder &&other) noexcept
MLOperand dequantizeLinear(const MLOperand &input, const MLOperand &scale, const MLOperand *zero_point=nullptr)
MLOperand cast(const MLOperand &input, MLOperandDataType data_type)
MLOperand input(const std::string &name, const MLOperandDescriptor &descriptor)
Declare a named graph input with the supplied type and shape.
MLOperand pad(const MLOperand &input, const std::vector< std::uint32_t > &beginning_padding, const std::vector< std::uint32_t > &ending_padding)
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 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 unary(RustnnUnaryOperation operation, const MLOperand &input, const MLOperatorOptions &options)
MLGraphBuilder & operator=(const MLGraphBuilder &)=delete
MLOperand softmax(const MLOperand &input, std::uint32_t axis)
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)
std::vector< std::uint64_t > operandShape(const MLOperand &operand)
Return an operand's inferred dimensions.
MLOperand binary(RustnnBinaryOperation operation, const MLOperand &lhs, const MLOperand &rhs)
MLGraphBuilder(MLContext &context)
std::vector< MLOperand > split(const MLOperand &input, std::uint32_t num_splits)
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 expand(const MLOperand &input, const std::vector< std::uint32_t > &new_shape)
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
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
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
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].
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 rustnn's pretty_env_logger global logger if no logger 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].
bool accelerated
Whether to prefer an accelerated device.
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.