Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ jobs:
with:
python-version: '3.10'
cache: 'pip'
- name: Clean system disk space
run: |
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
echo "Disk space after cleanup:"
df -h /
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[full]
make install
pip cache purge
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
- name: Run tests
run: make test
- name: Upload coverage report
Expand Down
3 changes: 3 additions & 0 deletions padiff/abstracts/hooks/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def info_hook(model, input, output, net_id):

# if this api is not processing tensors, do not create report
if output is None or all([not isinstance(x, (paddle.Tensor, torch.Tensor)) for x in flatten(output)]):
logger.warning_once(
f"All outputs of {model.__class__.__name__} are not tensors. Skip capturing these outputs."
)
return None

# if an api under black_list_recursively, do not create report
Expand Down
10 changes: 9 additions & 1 deletion padiff/tools/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from collections import defaultdict
import json
import os
import sys
Expand Down Expand Up @@ -130,6 +131,8 @@ def dump_report_node(wrap_node, tensor_dumper):


def dump_param_prototype(model, dump_fn, file_path):
skiped_layers = defaultdict(list)

def dump_param_with_fn(model, fn, target_models):
param_info = {
"name": model.class_name,
Expand All @@ -150,7 +153,7 @@ def dump_param_with_fn(model, fn, target_models):
if buffer_name not in params_found:
fn(buffer_name, buffer, param_info)
else:
logger.debug(f"Layer {model.class_name} ({model.route}) is NOT in target_models. Skipping.")
skiped_layers[model.class_name].append(model.route)

for name, child in model.named_children():
param_info["children"].append(dump_param_with_fn(child, fn, target_models))
Expand All @@ -159,6 +162,11 @@ def dump_param_with_fn(model, fn, target_models):
target_models = [layer.model for layer in model.marker.traversal_for_assign_weight()]
param_info = dump_param_with_fn(model, dump_fn, target_models)

logger.debug_once("Params dump SKIPPED: Some layers have no available parameters(like weights).\n")
for model_name, routes in skiped_layers.items():
routes_str = "\n".join([f" {route}" for route in routes])
logger.debug(f"Params dump SKIPPED: {model_name}.\nIncluded routes:\n{routes_str}")

model_info = {
"model_name": model.name,
"framework": model.framework,
Expand Down
4 changes: 4 additions & 0 deletions padiff/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def traverse(structure, on_leaf, on_container=None):
if isinstance(structure, (paddle.Tensor, torch.Tensor)):
return on_leaf(structure)

# numpy
if isinstance(structure, np.ndarray):
return on_leaf(structure)

# namedtuple
if hasattr(structure, "_fields"):
result = type(structure)(
Expand Down