def to_function_counts(count_strings: List[str],
                           inclusive: bool) -> benchmark_utils.FunctionCounts:
        data: List[benchmark_utils.FunctionCount] = []
        for cs in count_strings:
            # Storing entries as f"{c} {fn}" rather than [c, fn] adds some work
            # reviving the artifact, but it makes the json much easier to read.
            match = pattern.search(cs)
            assert match is not None
            c, fn = match.groups()
            data.append(
                benchmark_utils.FunctionCount(count=int(c), function=fn))

        return benchmark_utils.FunctionCounts(tuple(sorted(data,
                                                           reverse=True)),
                                              inclusive=inclusive)
    def test_manipulate_callgrind_stats(self):
        stats_no_data, stats_with_data = load_callgrind_artifacts()

        # Mock `torch.set_printoptions(linewidth=160)`
        wide_linewidth = benchmark_utils.FunctionCounts(
            stats_no_data.stats(inclusive=False)._data, False, 160)

        for l in repr(wide_linewidth).splitlines(keepends=False):
            self.assertLessEqual(len(l), 160)

        self.assertEqual(
            # `delta` is just a convenience method.
            stats_with_data.delta(stats_no_data)._data,
            (stats_with_data.stats() - stats_no_data.stats())._data)

        deltas = stats_with_data.as_standardized().delta(
            stats_no_data.as_standardized())

        def custom_transforms(fn: str):
            fn = re.sub(re.escape("/usr/include/c++/8/bits/"), "", fn)
            fn = re.sub(r"build/../", "", fn)
            fn = re.sub(".+" + re.escape("libsupc++"), "libsupc++", fn)
            return fn

        self.regularizeAndAssertExpectedInline(
            stats_no_data,
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.CallgrindStats object at 0xXXXXXXXXXXXX>
            y = torch.ones(())
                                       All          Noisy symbols removed
                Instructions:      8869966                    8728096
                Baseline:             6682                       5766
            1000 runs per measurement, 1 thread""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.counts(),
            """8869966""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.counts(denoise=True),
            """8728096""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.stats(),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr [/usr/lib64/ld-2.28.so]
              388193  ???:_int_free [/usr/lib64/libc-2.28.so]
              274000  build/../torch/csrc/utils/python ... rch/torch/lib/libtorch_python.so]
              264000  build/../aten/src/ATen/record_fu ... ytorch/torch/lib/libtorch_cpu.so]
              192000  build/../c10/core/Device.h:c10:: ... epos/pytorch/torch/lib/libc10.so]
              169855  ???:_int_malloc [/usr/lib64/libc-2.28.so]
              154000  build/../c10/core/TensorOptions. ... ytorch/torch/lib/libtorch_cpu.so]
              147167  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
              135000  ???:malloc [/usr/lib64/libc-2.28.so]
                 ...
                 -62  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                 -63  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                 -70  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                 -74  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                 -85  /home/test_user/miniconda3/envs/ ... rch/torch/lib/libtorch_python.so]
                 -95  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                -104  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                -134  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
                -180  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]

            Total: 8863284""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.stats(inclusive=True),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              8952420  ???:0x0000000000001050 [/usr/lib64/ld-2.28.so]
              8952420  ???:(below main) [/usr/lib64/libc-2.28.so]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8952420  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                  ...
                 -195  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                 -196  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                 -207  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                 -261  /home/test_user/miniconda3/envs/ ... ch/torch/lib/libtorch_python.so]
                 -561  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                 -789  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                 -881  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                -1196  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                -1206  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]""",
        )

        self.regularizeAndAssertExpectedInline(wide_linewidth, """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr [/usr/lib64/ld-2.28.so]
              388193  ???:_int_free [/usr/lib64/libc-2.28.so]
              274000  build/../torch/csrc/utils/python_arg_parser.cpp:torch::FunctionSignature ...  bool) [/data/users/test_user/repos/pytorch/torch/lib/libtorch_python.so]
              264000  build/../aten/src/ATen/record_function.cpp:at::RecordFunction::RecordFun ... ordScope) [/data/users/test_user/repos/pytorch/torch/lib/libtorch_cpu.so]
              192000  build/../c10/core/Device.h:c10::Device::validate() [/data/users/test_user/repos/pytorch/torch/lib/libc10.so]
              169855  ???:_int_malloc [/usr/lib64/libc-2.28.so]
              154000  build/../c10/core/TensorOptions.h:c10::TensorOptions::merge_in(c10::Tens ... ns) const [/data/users/test_user/repos/pytorch/torch/lib/libtorch_cpu.so]
              147167  /tmp/build/80754af9/python_1599604603603/work/Python/ceval.c:_PyEval_EvalFrameDefault [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
              135000  ???:malloc [/usr/lib64/libc-2.28.so]
                 ...
                 -62  /tmp/build/80754af9/python_1599604603603/work/Objects/abstract.c:PyNumber_Subtract [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                 -63  /tmp/build/80754af9/python_1599604603603/work/Objects/longobject.c:long_richcompare [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                 -70  /tmp/build/80754af9/python_1599604603603/work/Objects/abstract.c:_PyObject_FastCallDict [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                 -74  /tmp/build/80754af9/python_1599604603603/work/Python/pytime.c:_PyTime_FromSecondsObject [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                 -85  /home/test_user/miniconda3/envs/throwaway/include/pybind11/pybind11.h:py ... ject*) [/data/users/test_user/repos/pytorch/torch/lib/libtorch_python.so]
                 -95  /tmp/build/80754af9/python_1599604603603/work/Objects/rangeobject.c:rangeiter_next [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                -104  /tmp/build/80754af9/python_1599604603603/work/Objects/object.c:PyObject_RichCompare [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                -134  /tmp/build/80754af9/python_1599604603603/work/Objects/rangeobject.c:range_new [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
                -180  /tmp/build/80754af9/python_1599604603603/work/Objects/longobject.c:PyLong_FromLong [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]

            Total: 8863284"""

                                               # noqa
                                               )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.as_standardized().stats(),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr
              388193  ???:_int_free
              274000  build/../torch/csrc/utils/python ... ject*, _object*, _object**, bool)
              264000  build/../aten/src/ATen/record_fu ... ::RecordFunction(at::RecordScope)
              192000  build/../c10/core/Device.h:c10::Device::validate()
              169855  ???:_int_malloc
              154000  build/../c10/core/TensorOptions. ... erge_in(c10::TensorOptions) const
              147167  Python/ceval.c:_PyEval_EvalFrameDefault
              135000  ???:malloc
                 ...
                 -62  Objects/abstract.c:PyNumber_Subtract
                 -63  Objects/longobject.c:long_richcompare
                 -70  Objects/abstract.c:_PyObject_FastCallDict
                 -74  Python/pytime.c:_PyTime_FromSecondsObject
                 -85  /home/test_user/miniconda3/envs/ ... her(_object*, _object*, _object*)
                 -95  Objects/rangeobject.c:rangeiter_next
                -104  Objects/object.c:PyObject_RichCompare
                -134  Objects/rangeobject.c:range_new
                -180  Objects/longobject.c:PyLong_FromLong

            Total: 8863284""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas,
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
                85000  Objects/dictobject.c:lookdict_unicode
                59089  ???:_int_free
                43000  ???:malloc
                25000  build/../torch/csrc/utils/python ... :torch::PythonArgs::intlist(int)
                24000  ???:__tls_get_addr
                23000  ???:free
                21067  Objects/dictobject.c:lookdict_unicode_nodummy
                20000  build/../torch/csrc/utils/python ... :torch::PythonArgs::intlist(int)
                18000  Objects/longobject.c:PyLong_AsLongLongAndOverflow
                  ...
                 2000  /home/nwani/m3/conda-bld/compile ... del_op.cc:operator delete(void*)
                 1000  /usr/include/c++/8/bits/stl_vector.h:torch::PythonArgs::intlist(int)
                  193  ???:_int_malloc
                   75  ???:_int_memalign
                -1000  build/../c10/util/SmallVector.h: ... _contiguous(c10::ArrayRef<long>)
                -1000  build/../c10/util/SmallVector.h: ... nsor_restride(c10::MemoryFormat)
                -1000  /usr/include/c++/8/bits/stl_vect ... es(_object*, _object*, _object*)
                -8000  Python/ceval.c:_PyEval_EvalFrameDefault
               -16000  Objects/tupleobject.c:PyTuple_New

            Total: 432917""",
        )

        self.regularizeAndAssertExpectedInline(len(deltas), """35""")

        self.regularizeAndAssertExpectedInline(
            deltas.transform(custom_transforms),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
                85000  Objects/dictobject.c:lookdict_unicode
                59089  ???:_int_free
                43000  ???:malloc
                25000  torch/csrc/utils/python_numbers.h:torch::PythonArgs::intlist(int)
                24000  ???:__tls_get_addr
                23000  ???:free
                21067  Objects/dictobject.c:lookdict_unicode_nodummy
                20000  torch/csrc/utils/python_arg_parser.h:torch::PythonArgs::intlist(int)
                18000  Objects/longobject.c:PyLong_AsLongLongAndOverflow
                  ...
                 2000  c10/util/SmallVector.h:c10::TensorImpl::compute_contiguous() const
                 1000  stl_vector.h:torch::PythonArgs::intlist(int)
                  193  ???:_int_malloc
                   75  ???:_int_memalign
                -1000  stl_vector.h:torch::autograd::TH ... es(_object*, _object*, _object*)
                -1000  c10/util/SmallVector.h:c10::Tens ... _contiguous(c10::ArrayRef<long>)
                -1000  c10/util/SmallVector.h:c10::Tens ... nsor_restride(c10::MemoryFormat)
                -8000  Python/ceval.c:_PyEval_EvalFrameDefault
               -16000  Objects/tupleobject.c:PyTuple_New

            Total: 432917""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas.filter(lambda fn: fn.startswith("???")),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              59089  ???:_int_free
              43000  ???:malloc
              24000  ???:__tls_get_addr
              23000  ???:free
                193  ???:_int_malloc
                 75  ???:_int_memalign

            Total: 149357""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas[:5],
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              85000  Objects/dictobject.c:lookdict_unicode
              59089  ???:_int_free
              43000  ???:malloc
              25000  build/../torch/csrc/utils/python_ ... h:torch::PythonArgs::intlist(int)
              24000  ???:__tls_get_addr

            Total: 236089""",
        )
Exemple #3
0
    def test_manipulate_callgrind_stats(self):
        stats_no_data, stats_with_data = load_callgrind_artifacts()

        # Mock `torch.set_printoptions(linewidth=160)`
        wide_linewidth = benchmark_utils.FunctionCounts(
            stats_no_data.stats(inclusive=False)._data, False, _linewidth=160)

        for l in repr(wide_linewidth).splitlines(keepends=False):
            self.assertLessEqual(len(l), 160)

        self.assertEqual(
            # `delta` is just a convenience method.
            stats_with_data.delta(stats_no_data)._data,
            (stats_with_data.stats() - stats_no_data.stats())._data)

        deltas = stats_with_data.as_standardized().delta(
            stats_no_data.as_standardized())

        def custom_transforms(fn: str):
            fn = re.sub(re.escape("/usr/include/c++/8/bits/"), "", fn)
            fn = re.sub(r"build/../", "", fn)
            fn = re.sub(".+" + re.escape("libsupc++"), "libsupc++", fn)
            return fn

        self.regularizeAndAssertExpectedInline(
            stats_no_data,
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.CallgrindStats object at 0xXXXXXXXXXXXX>
            y = torch.ones(())
                                       All          Noisy symbols removed
                Instructions:      8869966                    8728096
                Baseline:             6682                       5766
            1000 runs per measurement, 1 thread""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.counts(),
            """8869966""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.counts(denoise=True),
            """8728096""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.stats(),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr [/usr/lib64/ld-2.28.so]
              388193  ???:_int_free [/usr/lib64/libc-2.28.so]
              274000  build/../torch/csrc/utils/python ... rch/torch/lib/libtorch_python.so]
              264000  build/../aten/src/ATen/record_fu ... ytorch/torch/lib/libtorch_cpu.so]
              192000  build/../c10/core/Device.h:c10:: ... epos/pytorch/torch/lib/libc10.so]
              169855  ???:_int_malloc [/usr/lib64/libc-2.28.so]
              154000  build/../c10/core/TensorOptions. ... ytorch/torch/lib/libtorch_cpu.so]
              148561  /tmp/build/80754af9/python_15996 ... da3/envs/throwaway/bin/python3.6]
              135000  ???:malloc [/usr/lib64/libc-2.28.so]
                 ...
                2000  /usr/include/c++/8/ext/new_allocator.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/stl_vect ... *, _object*, _object*, _object**)
                2000  /usr/include/c++/8/bits/stl_vect ... rningHandler::~PyWarningHandler()
                2000  /usr/include/c++/8/bits/stl_vect ... ject*, _object*, _object**, bool)
                2000  /usr/include/c++/8/bits/stl_algobase.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/shared_p ... ad_accumulator(at::Tensor const&)
                2000  /usr/include/c++/8/bits/move.h:c ... te<c10::AutogradMetaInterface> >)
                2000  /usr/include/c++/8/bits/atomic_b ... DispatchKey&&, caffe2::TypeMeta&)
                2000  /usr/include/c++/8/array:at::Ten ... , at::Tensor&, c10::Scalar) const

            Total: 8869966""",
        )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.stats(inclusive=True),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              8959166  ???:0x0000000000001050 [/usr/lib64/ld-2.28.so]
              8959166  ???:(below main) [/usr/lib64/libc-2.28.so]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
              8959166  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                  ...
                92821  /tmp/build/80754af9/python_15996 ... a3/envs/throwaway/bin/python3.6]
                91000  build/../torch/csrc/tensor/pytho ... ch/torch/lib/libtorch_python.so]
                91000  /data/users/test_user/repos/pyto ... nsors::get_default_scalar_type()
                90090  ???:pthread_mutex_lock [/usr/lib64/libpthread-2.28.so]
                90000  build/../c10/core/TensorImpl.h:c ... ch/torch/lib/libtorch_python.so]
                90000  build/../aten/src/ATen/record_fu ... torch/torch/lib/libtorch_cpu.so]
                90000  /data/users/test_user/repos/pyto ... uard(c10::optional<c10::Device>)
                90000  /data/users/test_user/repos/pyto ... ersionCounter::~VersionCounter()
                88000  /data/users/test_user/repos/pyto ... ratorKernel*, at::Tensor const&)""",
        )

        self.regularizeAndAssertExpectedInline(wide_linewidth, """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr [/usr/lib64/ld-2.28.so]
              388193  ???:_int_free [/usr/lib64/libc-2.28.so]
              274000  build/../torch/csrc/utils/python_arg_parser.cpp:torch::FunctionSignature ...  bool) [/data/users/test_user/repos/pytorch/torch/lib/libtorch_python.so]
              264000  build/../aten/src/ATen/record_function.cpp:at::RecordFunction::RecordFun ... ordScope) [/data/users/test_user/repos/pytorch/torch/lib/libtorch_cpu.so]
              192000  build/../c10/core/Device.h:c10::Device::validate() [/data/users/test_user/repos/pytorch/torch/lib/libc10.so]
              169855  ???:_int_malloc [/usr/lib64/libc-2.28.so]
              154000  build/../c10/core/TensorOptions.h:c10::TensorOptions::merge_in(c10::Tens ... ns) const [/data/users/test_user/repos/pytorch/torch/lib/libtorch_cpu.so]
              148561  /tmp/build/80754af9/python_1599604603603/work/Python/ceval.c:_PyEval_EvalFrameDefault [/home/test_user/miniconda3/envs/throwaway/bin/python3.6]
              135000  ???:malloc [/usr/lib64/libc-2.28.so]
                 ...
                2000  /usr/include/c++/8/ext/new_allocator.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/stl_vector.h:torch::PythonArgParser::raw_parse(_object*, _object*, _object*, _object**)
                2000  /usr/include/c++/8/bits/stl_vector.h:torch::PyWarningHandler::~PyWarningHandler()
                2000  /usr/include/c++/8/bits/stl_vector.h:torch::FunctionSignature::parse(_object*, _object*, _object*, _object**, bool)
                2000  /usr/include/c++/8/bits/stl_algobase.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/shared_ptr_base.h:torch::autograd::impl::try_get_grad_accumulator(at::Tensor const&)
                2000  /usr/include/c++/8/bits/move.h:c10::TensorImpl::set_autograd_meta(std::u ... AutogradMetaInterface, std::default_delete<c10::AutogradMetaInterface> >)
                2000  /usr/include/c++/8/bits/atomic_base.h:at::Tensor at::detail::make_tensor ... t_null_type<c10::StorageImpl> >&&, c10::DispatchKey&&, caffe2::TypeMeta&)
                2000  /usr/include/c++/8/array:at::Tensor& c10::Dispatcher::callWithDispatchKe ... , c10::Scalar)> const&, c10::DispatchKey, at::Tensor&, c10::Scalar) const

            Total: 8869966"""

                                               # noqa
                                               )

        self.regularizeAndAssertExpectedInline(
            stats_no_data.as_standardized().stats(),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              408000  ???:__tls_get_addr
              388193  ???:_int_free
              274000  build/../torch/csrc/utils/python ... ject*, _object*, _object**, bool)
              264000  build/../aten/src/ATen/record_fu ... ::RecordFunction(at::RecordScope)
              192000  build/../c10/core/Device.h:c10::Device::validate()
              169855  ???:_int_malloc
              154000  build/../c10/core/TensorOptions. ... erge_in(c10::TensorOptions) const
              148561  Python/ceval.c:_PyEval_EvalFrameDefault
              135000  ???:malloc
                 ...
                2000  /usr/include/c++/8/ext/new_allocator.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/stl_vect ... *, _object*, _object*, _object**)
                2000  /usr/include/c++/8/bits/stl_vect ... rningHandler::~PyWarningHandler()
                2000  /usr/include/c++/8/bits/stl_vect ... ject*, _object*, _object**, bool)
                2000  /usr/include/c++/8/bits/stl_algobase.h:torch::PythonArgs::intlist(int)
                2000  /usr/include/c++/8/bits/shared_p ... ad_accumulator(at::Tensor const&)
                2000  /usr/include/c++/8/bits/move.h:c ... te<c10::AutogradMetaInterface> >)
                2000  /usr/include/c++/8/bits/atomic_b ... DispatchKey&&, caffe2::TypeMeta&)
                2000  /usr/include/c++/8/array:at::Ten ... , at::Tensor&, c10::Scalar) const

            Total: 8869966""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas,
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
                85000  Objects/dictobject.c:lookdict_unicode
                59089  ???:_int_free
                43000  ???:malloc
                25000  build/../torch/csrc/utils/python ... :torch::PythonArgs::intlist(int)
                24000  ???:__tls_get_addr
                23000  ???:free
                21067  Objects/dictobject.c:lookdict_unicode_nodummy
                20000  build/../torch/csrc/utils/python ... :torch::PythonArgs::intlist(int)
                18000  Objects/longobject.c:PyLong_AsLongLongAndOverflow
                  ...
                 2000  /home/nwani/m3/conda-bld/compile ... del_op.cc:operator delete(void*)
                 1000  /usr/include/c++/8/bits/stl_vector.h:torch::PythonArgs::intlist(int)
                  193  ???:_int_malloc
                   75  ???:_int_memalign
                -1000  build/../c10/util/SmallVector.h: ... _contiguous(c10::ArrayRef<long>)
                -1000  build/../c10/util/SmallVector.h: ... nsor_restride(c10::MemoryFormat)
                -1000  /usr/include/c++/8/bits/stl_vect ... es(_object*, _object*, _object*)
                -8000  Python/ceval.c:_PyEval_EvalFrameDefault
               -16000  Objects/tupleobject.c:PyTuple_New

            Total: 432917""",
        )

        self.regularizeAndAssertExpectedInline(len(deltas), """35""")

        self.regularizeAndAssertExpectedInline(
            deltas.transform(custom_transforms),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
                85000  Objects/dictobject.c:lookdict_unicode
                59089  ???:_int_free
                43000  ???:malloc
                25000  torch/csrc/utils/python_numbers.h:torch::PythonArgs::intlist(int)
                24000  ???:__tls_get_addr
                23000  ???:free
                21067  Objects/dictobject.c:lookdict_unicode_nodummy
                20000  torch/csrc/utils/python_arg_parser.h:torch::PythonArgs::intlist(int)
                18000  Objects/longobject.c:PyLong_AsLongLongAndOverflow
                  ...
                 2000  c10/util/SmallVector.h:c10::TensorImpl::compute_contiguous() const
                 1000  stl_vector.h:torch::PythonArgs::intlist(int)
                  193  ???:_int_malloc
                   75  ???:_int_memalign
                -1000  stl_vector.h:torch::autograd::TH ... es(_object*, _object*, _object*)
                -1000  c10/util/SmallVector.h:c10::Tens ... _contiguous(c10::ArrayRef<long>)
                -1000  c10/util/SmallVector.h:c10::Tens ... nsor_restride(c10::MemoryFormat)
                -8000  Python/ceval.c:_PyEval_EvalFrameDefault
               -16000  Objects/tupleobject.c:PyTuple_New

            Total: 432917""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas.filter(lambda fn: fn.startswith("???")),
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              59089  ???:_int_free
              43000  ???:malloc
              24000  ???:__tls_get_addr
              23000  ???:free
                193  ???:_int_malloc
                 75  ???:_int_memalign

            Total: 149357""",
        )

        self.regularizeAndAssertExpectedInline(
            deltas[:5],
            """\
            <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0xXXXXXXXXXXXX>
              85000  Objects/dictobject.c:lookdict_unicode
              59089  ???:_int_free
              43000  ???:malloc
              25000  build/../torch/csrc/utils/python_ ... h:torch::PythonArgs::intlist(int)
              24000  ???:__tls_get_addr

            Total: 236089""",
        )