Skip to content

Instantly share code, notes, and snippets.

14:03 $ python export.py
I0221 15:44:29.689399 8453013824 xla_bridge.py:170] Remote TPU is not linked into jax; skipping remote TPU.
I0221 15:44:29.689505 8453013824 xla_bridge.py:421] Unable to initialize backend 'tpu_driver': Could not initialize backend 'tpu_driver'
I0221 15:44:29.689548 8453013824 xla_bridge.py:421] Unable to initialize backend 'cuda': module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'
I0221 15:44:29.689573 8453013824 xla_bridge.py:421] Unable to initialize backend 'rocm': module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'
I0221 15:44:29.689785 8453013824 xla_bridge.py:421] Unable to initialize backend 'tpu': module 'jaxlib.xla_extension' has no attribute 'get_tpu_client'
I0221 15:44:29.689874 8453013824 xla_bridge.py:421] Unable to initialize backend 'plugin': xla_extension has no attributes named get_plugin_device_client. Compile TensorFlow with //tensorflow/compiler/xla/python:enable_plugin_device set to true (defaults to false) to enable this.
Traceba
%1140 = stablehlo.broadcast_in_dim %1139, dims = [] : (tensor<i32>) -> tensor<500x256xi32>
%1141 = stablehlo.multiply %1136, %1140 : tensor<500x256xi32>
%1142 = stablehlo.constant dense<999993> : tensor<i64>
%1143 = call @jit__train_step_kernel$remainder_4(%1141, %1142) : (tensor<500x256xi32>, tensor<i64>) -> tensor<500x256xi32>
%1144 = stablehlo.broadcast_in_dim %arg9, dims = [1] : (tensor<256xi32>) -> tensor<1x256xi32>
%1145 = stablehlo.broadcast_in_dim %1144, dims = [0, 1] : (tensor<1x256xi32>) -> tensor<500x256xi32>
%1146 = stablehlo.add %1143, %1145 : tensor<500x256xi32>
%1147 = stablehlo.constant dense<0> : tensor<i32>
%1148 = stablehlo.broadcast_in_dim %1147, dims = [] : (tensor<i32>) -> tensor<500x256xi32>
%1149 = stablehlo.compare LT, %1146, %1148, SIGNED : (tensor<500x256xi32>, tensor<500x256xi32>) -> tensor<500x256xi1>
13:04 $ python model.py | tee /tmp/hashemb.mlir | iree-compile - --iree-hal-target-backends=llvm-cpu --iree-input-type=mhlo --iree-mhlo-demote-i64-to-i32=false > /tmp/x.vmfb
<stdin>:1223:13: error: 'iree_linalg_ext.scatter' op indexed shape of update value dim#1 exceeds original value at dim#0 64 -9223372036854775808
%1178 = "stablehlo.scatter"(%1177, %1162, %1175) ({
^
<stdin>:21:12: note: called from
%8:5 = call @jit__train_step_kernel$main(%arg0, %arg1, %0, %1, %2, %3, %4, %5, %6, %7) : (tensor<512x19xi32>, tensor<512xi32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<2xui32>, tensor<681022xi32>, tensor<11xi32>, tensor<256xi32>, tensor<256xi32>) -> (tensor<1000000xf32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<2xui32>, tensor<f32>)
^
<stdin>:1223:13: note: see current operation:
%19 = "iree_linalg_ext.scatter"(%0, %5, %18) ({
^bb0(%arg3: f32, %arg4: f32):
@wangkuiyi
wangkuiyi / compile-error.txt
Last active February 17, 2023 06:36
Compile a embedding table lookup program
22:08 $ python model.py | iree-compile - --iree-hal-target-backends=llvm-cpu --iree-input-type=mhlo --iree-mhlo-demote-i64-to-i32=false > /tmp/x.vmfb
<stdin>:1192:13: error: 'vector.broadcast' op dimension mismatch (4 vs. 0)
%1155 = "stablehlo.gather"(%arg2, %1154) {dimension_numbers = #stablehlo.gather<collapsed_slice_dims = [0], start_index_map = [0], index_vector_dim = 2>, indices_are_sorted = false, slice_sizes = dense<1> : tensor<1xi64>} : (tensor<1000000xf32>, tensor<500x256x1xi32>) -> tensor<500x256xf32>
^
<stdin>:21:12: note: called from
%8:5 = call @jit__train_step_kernel$main(%arg0, %arg1, %0, %1, %2, %3, %4, %5, %6, %7) : (tensor<512x19xi32>, tensor<512xi32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<2xui32>, tensor<681022xi32>, tensor<11xi32>, tensor<256xi32>, tensor<256xi32>) -> (tensor<1000000xf32>, tensor<1000000xf32>, tensor<1000000xf32>, tensor<2xui32>, tensor<f32>)
^
<stdin>:1192:13: note: see current operation: %32 = "vector.broadc
# https://gist.github.com/Jatapiaro/6a7c769a07911adc629e1604729d4c7a
qemu-system-x86_64 \
-m 2048 \
-vga virtio \
-usb \
-device usb-tablet \
-drive file=haiku-drive.qcow2,if=virtio
# Will need the following option if we are gonna install Haiku.
# -cdrom haiku.iso \
@wangkuiyi
wangkuiyi / stdout-stderr-iree-jax-test_jax.py.txt
Created February 4, 2023 22:59
The stdout and stderror from runnign iree-jax/models/gpt2/test_jax.py
(iree-jax) ✔ ~/w/iree-ios/iree-jax/models/gpt2 [main|…2]
14:38 $ python test_jax.py
Running tests under Python 3.10.8: /Users/y/miniforge3/envs/iree-jax/bin/python
[ RUN ] GPT2RealWeightsTest.test_batch_one0 ('cpu')
I0204 14:45:40.467961 8235580032 xla_bridge.py:170] Remote TPU is not linked into jax; skipping remote TPU.
I0204 14:45:40.468046 8235580032 xla_bridge.py:355] Unable to initialize backend 'tpu_driver': Could not initialize backend 'tpu_driver'
I0204 14:45:40.468080 8235580032 xla_bridge.py:355] Unable to initialize backend 'cuda': module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'
I0204 14:45:40.468105 8235580032 xla_bridge.py:355] Unable to initialize backend 'rocm': module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'
I0204 14:45:40.468208 8235580032 xla_bridge.py:355] Unable to initialize backend 'tpu': module 'jaxlib.xla_extension' has no attribute 'get_tpu_client'
I0204 14:45:40.468249 8235580032 xla_bridge.py:355] Unable to initialize backend 'plugin': x
@wangkuiyi
wangkuiyi / interweave.py
Created January 29, 2023 06:32
Converts a Python script that prints an MLIR into a Markdown section
# Run the following command to convert 01-double.py into a Markdown section.
#
# python interweave_python_mlir.py python_file
#
# Requirements:
#
# 1. Running the python_file must prints the MLIR source code.
#
# 2. If there is a comments of a number before a Python code block in
# python_file, the number is the number of lines of the MLIR source
@wangkuiyi
wangkuiyi / iree_macos_ios_ci.dot
Created January 25, 2023 01:58
IREE macOS/iOS CI steps
digraph G {
node [shape=plaintext];
iree_runtime [label="IREE runtime\nsource code"];
iree_compiler [label="IREE compiler\nsource code"];
cmake [label="CMake", shape=rect];
rt_ios_dev [label="iree.framework for\narm64 iOS devices"];
-- Configuring done
CMake Warning (dev) at /Users/y/w/iree/third_party/googletest/googletest/cmake/internal_utils.cmake:159 (add_library):
Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
enabled. Run "cmake --help-policy CMP0069" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
INTERPROCEDURAL_OPTIMIZATION property will be ignored for target 'gmock'.
Call Stack (most recent call first):
/Users/y/w/iree/third_party/googletest/googletest/cmake/internal_utils.cmake:213 (cxx_library_with_type)
/Users/y/w/iree/third_party/googletest/googlemock/CMakeLists.txt:97 (cxx_library)
@wangkuiyi
wangkuiyi / Info.plist
Created January 6, 2023 20:55
My manually edited Info.plist file for `iree_run_module.app`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>iree-run-module</string>
<key>CFBundleGetInfoString</key>
<string></string>