-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hello, @takeshi-yoshimura !
Recently, I consider to seperate the torch and paddle. Maybe, we only need a framework support (torch or paddle), we can successfully run fastsafetensors.
In current main branch, we must depend on torch, even though we only want to use paddle. Because we import torch directly, such as following code
# fastsafetensors/common.py
import torch
try:
import paddle
from paddle.framework import core as paddle_core
paddle_loaded = True
except:
paddle_loaded = False
...In my opinion, the first plan, maybe we can also set a tag torch_loaded to enable the case that we only install paddle like following code
# fastsafetensors/common.py
try:
import torch
torch_loaded = true
except:
torch_loaded = False
try:
import paddle
from paddle.framework import core as paddle_core
paddle_loaded = True
except:
paddle_loaded = False
if not torch_loaded and not paddle_loaded:
raise ....
...The second plan, we can seperate the implement of torch and paddle to two modules. If we only want to use paddle, we can load the API from fastsafetensors.paddle.
It means that origin files structure:
fastsafetensors
├── common.py
├── copier
│ ├── gds.py
│ └── nogds.py
├── dlpack.py
├── file_buffer.py
├── __init__.py
├── loader.py
└── tensor_factory.pywill be change to the following structure.
fastsafetensors
├── cpp
│ ├── ext.cpp
│ └── ext.hpp
├── paddle # follow files imply by paddle
│ ├── common.py
│ ├── copier
│ │ ├── gds.py
│ │ └── nogds.py
│ ├── dlpack.py
│ ├── file_buffer.py
│ ├── __init__.py
│ ├── loader.py
│ └── tensor_factory.py
└── torch # follow files imply by torch
├── common.py
├── copier
│ ├── gds.py
│ └── nogds.py
├── dlpack.py
├── file_buffer.py
├── __init__.py
├── loader.py
└── tensor_factory.pyWhich plan do you wish? I will create my PR soon if you choose a plan. Of course, you can also share your other opinions with me.