Feat/user defined layers #7
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the ability to register and parse custom layers for both TensorFlow and PyTorch backends in VGSLify. It also introduces a few breaking changes related to file organization and simplifies import paths to make the library easier to use.
New Features
Custom Layer Registration (TensorFlow and PyTorch)
You can now register custom layer builder functions directly with the
TensorFlowLayerFactoryand (similarly) with the Torch layer factory.Alternatively, use the new decorator approach:
This allows users to incorporate any custom TensorFlow or PyTorch layers into a VGSL specification simply by providing a prefix and builder function.
Custom Parser Registration for Model -> Spec
To convert a custom layer back into a VGSL specification, you can now register parser functions:
These functions are then picked up automatically by the parser (
TensorFlowModelParserorTorchModelParser) to handle custom layers.Breaking Changes
Module Renaming and Reorganization
vgslify.parsersis nowvgslify.model_parsers.tf_parser.py,torch_parser.py, andbase_parser.pyhave been reorganized intotensorflow/,torch/, andbase/directories respectively.vgslify.core.parseris now calledvgslify.core.spec_parser.Simplified Imports
You can now import the main classes and utilities more directly:
Parser imports have been simplified:
Layer factory imports have also been unified:
Example Usage