facebookresearch / HolisticTraceAnalysis

A library to analyze PyTorch traces.
http://hta.readthedocs.io
MIT License
270 stars 37 forks source link

Feature Request: Implement `data_provider` Utility for HTA #172

Open fengxizhou opened 1 month ago

fengxizhou commented 1 month ago

🚀 Motivation and context

We propose implementing of a data_provider utility within the HTA project. This utility aims to standardize data provisioning across various the unit tests, improving compatibility and code consistencies.

Currently, there are data_provider utilities in both Meta internal codebases and external projects. However, these existing tools are not compatible with each other, leading to inefficiencies and integration issues when porting test cases.

Description

To alleviate the above pain points, we plan to create a data_provider utility which matches the same interface provided by the Meta "data_provider" interface.

The usage of the data_provider is as follows:

class TestTransform(unittest.TestCase):
    # pyre-ignore[56]
    def dataset():
        return (
          {'input_1': 'hello', 'expected_result': 'HeLlO'},
          {'input_1': 'world', 'expected_result': 'WoRlD'},
        )

    @data_provider(dataset)
    def test_transform(self, input_1: str,  expected_result: str):
        self.assertEqual(transform(input_1), expected_result)

    # pyre-ignore[56]
    @data_provider(
       lambda: (
          {'input_1': 'hello', 'expected_result': 'HeLlO'},
          {'input_1': 'world', 'expected_result': 'WoRlD'},
        )
     )
    def test_transform2(self, input_1: str,  expected_result: str):
        self.assertEqual(transform(input_1), expected_result)

Alternatives

No response

Additional context

No response