Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
| """ | |
| DyNet implementation of a sequence labeler (POS taggger). | |
| This is a translation of this tagger in PyTorch: https://gist.github.com/hal3/8c170c4400576eb8d0a8bd94ab231232 | |
| Basic architecture: | |
| - take words | |
| - run though bidirectional GRU | |
| - predict labels one word at a time (left to right), using a recurrent neural network "decoder" | |
| The decoder updates hidden state based on: | |
| - most recent word |
| #import <Foundation/Foundation.h> | |
| #import <time.h> | |
| #import <os/lock.h> | |
| #define ITERS 2000 | |
| #define NSEC_PER_ITER(time) (((double)time * (double)NSEC_PER_SEC) / (double)ITERS) | |
| #define TEST(body, name) do {\ | |
| start = [NSDate date];\ | |
| for (int i = 0; i < ITERS; i++) {\ |
Technical details for https://stackoverflow.com/a/44169445/6730571
On a base system, /usr/bin/java is a symlink that points to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, which is an Apple wrapper tool that locates and executes the actual java.
(Do not touch anything in those 2 system directories. It should actually be impossible due to "System Integrity Protection" anyway.)
If you don't have Java installed, attempting to execute java will open a dialog that invites you to install it.
| @import Foundation; | |
| @import CoreGraphics; | |
| typedef struct __attribute__((objc_boxable)) CGPoint CGPoint; | |
| typedef struct __attribute__((objc_boxable)) CGSize CGSize; | |
| typedef struct __attribute__((objc_boxable)) CGRect CGRect; | |
| typedef struct __attribute__((objc_boxable)) CGVector CGVector; | |
| int main(int argc, const char * argv[]) { | |
| @autoreleasepool { |
| import org.nd4j.linalg.api.ndarray.INDArray | |
| import org.nd4j.linalg.api.ops.impl.broadcast.BroadcastAddOp | |
| import org.nd4j.linalg.api.rng.distribution.impl.UniformDistribution | |
| import org.nd4j.linalg.factory.Nd4j | |
| import scala.util.Random | |
| object Xavier { | |
| def init(shape: Array[Int]): INDArray = { | |
| var n = shape.dropRight(1).product |
| import java.lang.instrument.Instrumentation; | |
| import java.lang.reflect.Layer; | |
| import java.lang.reflect.Module; | |
| import java.util.*; | |
| public class WeakeningAgent { | |
| public static void premain(String argument, Instrumentation instrumentation) { | |
| boolean full = argument != null && argument.equals("full"); | |
| Set<Module> importing = new HashSet<>(), exporting = new HashSet<>(); |
| # The trick is to link the DeviceSupport folder from the beta to the stable version. | |
| # sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :) | |
| # Support iOS 15 devices (Xcode 13.0) with Xcode 12.5: | |
| sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
| # Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions | |
| # (A similar approach works for older versions too, just change the version number after DeviceSupport) |