This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto a = op::uniform(-20.0, 20.0, {2, 5}).astype(dtype); | |
| a.eval(); | |
| auto exped = op::exp(a - op::max(a, {-1}, true)); | |
| auto fused_softmax = exped / op::sum(exped, {-1}, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Access Pattern Search | |
| --------------------- | |
| Code for simulating the effect of searching for the right access pattern in | |
| a CUDA Kernel computation directed acyclic graph. | |
| The key idea is to have every node in the computation graph return an object | |
| representing "for loops" that can be optionally parallelized using blocks | |
| or threads (followed by syncs). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clear_subl { | |
| python3 -c "path = '~/Library/Application Support/Sublime Text 3/Local/Auto Save Session.sublime_session'; import os, json; data = json.load(open(os.path.expanduser(path), 'rt')); data['windows'] = []; json.dump(data, open(os.path.expanduser(path), 'wt'))" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from contextlib import contextmanager | |
| import time | |
| CURRENT_SCOPE = [] | |
| @contextmanager | |
| def printing_scope(message): | |
| CURRENT_SCOPE.append(message) | |
| yield | |
| last = CURRENT_SCOPE.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from ortools.constraint_solver import pywrapcp | |
| import numpy as np | |
| def _create_distance_callback(dist_matrix): | |
| # Create a callback to calculate distances between cities. | |
| def distance_callback(from_node, to_node): | |
| return int(dist_matrix[from_node][to_node]) | |
| return distance_callback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def save_submission(predictions, filename): | |
| "Take model output & save for cardinality estimation benchmark upload.""" | |
| np.save(filename, np.array([value for item in predictions for key, value in sorted(item.items())])) | |
| # preds = rf.test(testqs) # run your prediction code on the test data | |
| save_submission(preds, "mysubmission.npy") | |
| # Then Upload "mysubmission.npy" to the leaderboard https://mlforsystems.wl.r.appspot.com :) |
OlderNewer