Skip to main content

Module tensor_source

Module tensor_source 

Source
Expand description

Tensor Source Registry

This module manages external tensor data (images, embeddings, etc.) that can be indexed by neural predicates during proof search.

§Architecture

In DeepProbLog-style programs, neural predicates reference external data:

nn(mnist_net, [X], Y, [0..9]) :: digit(X, Y).
?- digit(42, Y).  // X=42 indexes into tensor source

The tensor source registry:

  • Stores named tensor sources (train, test, etc.)
  • Tracks the “active” source for current evaluation
  • Validates indices are within bounds
  • Holds PyTorch tensors via PyO3 (when python feature enabled)

§Usage

use xlog_neural::tensor_source::{TensorSourceRegistry, TensorMetadata};

let mut registry = TensorSourceRegistry::new();

// Add sources with metadata
registry.add_with_metadata("train", TensorMetadata::new(60000, vec![1, 28, 28]));
registry.add_with_metadata("test", TensorMetadata::new(10000, vec![1, 28, 28]));

// Set active source
registry.set_active("train").unwrap();

// Validate index before neural call
registry.check_index(42).unwrap();

Structs§

TensorMetadata
Metadata about a tensor source (without the actual tensor data).
TensorSourceRegistry
Registry for managing tensor sources.

Enums§

TensorSourceError
Errors from tensor source operations.