2023-07-25 16:53:57 +00:00
|
|
|
from abc import abstractmethod
|
2023-09-07 02:42:59 +00:00
|
|
|
from typing import Any, Callable, Iterator, Optional
|
2023-07-25 16:53:57 +00:00
|
|
|
|
|
|
|
import torch
|
|
|
|
|
|
|
|
from colossalai.interface import ModelWrapper, OptimizerWrapper
|
|
|
|
|
|
|
|
from .plugin_base import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
class PipelinePluginBase(Plugin):
|
|
|
|
@abstractmethod
|
2023-09-19 06:20:26 +00:00
|
|
|
def execute_pipeline(
|
|
|
|
self,
|
|
|
|
data_iter: Iterator,
|
|
|
|
model: ModelWrapper,
|
|
|
|
criterion: Callable[[Any, Any], torch.Tensor],
|
|
|
|
optimizer: Optional[OptimizerWrapper] = None,
|
|
|
|
return_loss: bool = True,
|
|
|
|
return_outputs: bool = False,
|
|
|
|
) -> dict:
|
2023-07-25 16:53:57 +00:00
|
|
|
pass
|