惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
小众软件
小众软件
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
Microsoft Security Blog
Microsoft Security Blog
Last Week in AI
Last Week in AI
H
Help Net Security
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
腾讯CDC

OpenAI News

Using custom GPTs ChatGPT for customer success teams Applications of AI at OpenAI Research with ChatGPT Analyzing data with ChatGPT Financial services Responsible and safe use of AI Writing with ChatGPT ChatGPT for research Creating images with ChatGPT Personalizing ChatGPT ChatGPT for finance teams Getting started with ChatGPT Working with files in ChatGPT Learn ChatGPT workflows for sales teams Prompting fundamentals ChatGPT for managers Using projects in ChatGPT Learn ChatGPT workflows for marketing teams Brainstorming with ChatGPT AI fundamentals ChatGPT for operations teams Healthcare Our response to the Axios developer tool compromise Using skills OpenAI Full Fan Mode Contest: Terms & Conditions CyberAgent moves faster with ChatGPT Enterprise and Codex The next phase of enterprise AI 儿童安全蓝图正式发布 推出 OpenAI 安全研究员计划
Block-sparse GPU kernels
2017-12-06 · via OpenAI News

1

from blocksparse.matmul import BlocksparseMatMul

2

import tensorflow as tf

3

import numpy as np

4

5

hidden_size = 4096

6

block_size = 32

7

minibatch_size = 64

8

9

# Create a (random) sparsity pattern

10

sparsity = np.random.randint(2, size=(hidden_size//block_size,hidden_size//block_size))

11

12

# Initialize the sparse matrix multiplication object

13

bsmm = BlocksparseMatMul(sparsity, block_size=block_size)

14

15

# Input to graph

16

x = tf.placeholder(tf.float32, shape=[None, hidden_size])

17

18

# Initialize block-sparse weights

19

w = tf.get_variable("w", bsmm.w_shape, dtype=tf.float32)

20

21

# Block-sparse matrix multiplication

22

y = bsmm(x, w)

23

24

# Run

25

sess = tf.InteractiveSession()

26

sess.run(tf.global_variables_initializer())

27

result = sess.run([y], feed_dict = {x: np.ones((minibatch_size,hidden_size), dtype='float32')})

28

print(result)