Skip to content

Btrainwilson/tensor-mosaic

Repository files navigation

Mosaic
(tensor-mosaic)

Mosaic logo

Flexible tensor view allocator and cache for deep learning and scientific computing.

PyPI version Supported Python versions Build Status Documentation Status Coverage Status


Overview

Mosaic is a lightweight, extensible Python library for allocating and caching non-overlapping, named regions (views or slices) within large or dynamically constructed tensors.

It is especially useful for deep learning, scientific computing, and any application requiring efficient management and lookup of structured tensor subspaces.

  • Reserve and cache named slices: Create stable, named regions within tensors for models, optimizers, or data pipelines.
  • Device-aware: Automatically keeps cached indices and slices on the desired device (CPU/GPU).
  • Zero-copy views: Retrieve direct views into the underlying tensor without data duplication.
  • Compatible with PyTorch and NumPy.

Installation

pip install tensor-mosaic

Quick Start


import torch
import tensor_mosaic as mosaic  # Alias locally if you like

mosaic = mosaic.Mosaic()
mosaic.INPUTS = 16
mosaic.HIDDEN = 32
mosaic.OUTPUTS = 10

tensor = torch.randn(1, *mosaic.shape)  # Reserve total width

inputs_view = mosaic.slice_view(tensor, "inputs")
outputs_view = mosaic["outputs"]

print("Inputs:", inputs_view)
print("Outputs:", outputs_view)

About

No description, website, or topics provided.

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published