zoukankan      html  css  js  c++  java
  • tensorflow aot

    bazel build --define=with_xla_support=true --config=opt //tensorflow/tools/pip_package:build_pip_package 

    bazel build --config=opt //tensorflow:libtensorflow_cc.so --define=with_xla_support=true

    bazel build --config=opt //tensorflow/compiler/aot:tfcompile_lib

    bazel build --config=opt //tensorflow/compiler/aot:tfcompile

    saved_model_cli show --dir ../liner  --all

    saved_model_cli aot_compile_cpu  --dir ./liner --tag_set serve --output_prefix ./myaot2/myadd --cpp_class MyAdd --signature_def_key serving_default

    bazel build --config=opt //tensorflow/compiler/tf2xla:xla_compiled_cpu_function

    g++ -o main main.cc     -L../aot -lxla_compiled_cpu_function  -ltensorflow_cc -ltensorflow_framework -I/usr/local/lib/python3.6/dist-packages/tensorflow/include/  -L../../tensorflow/bazel-bin/tensorflow/compiler/tf2xla myadd_metadata.o myadd.o

    bazel build --config=opt //tensorflow/compiler/xla:executable_run_options

    g++ -o main main.cc     -L../aot     -I/usr/local/lib/python3.6/dist-packages/tensorflow/include/  ../../tensorflow/bazel-bin/tensorflow/compiler/tf2xla/libxla_compiled_cpu_function.a myadd_metadata.o myadd.o ../../tensorflow/bazel-bin/tensorflow/compiler/xla/libcpu_function_runtime.a  ../../tensorflow/bazel-bin/tensorflow/compiler/xla/libexecutable_run_options.a

    g++ -o test2 test2.cc -ltensorflow_cc -ltensorflow_framework  -I/usr/local/lib/python3.6/dist-packages/tensorflow/include/ -I../tensorflow/tensorflow/third_party

    import tensorflow.compat.v1 as tf
    tf.disable_v2_behavior()
    
    import numpy as np
    
    learning_rate=0.01
    training_epochs=1000
    display_step=50
    
    train_X=np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,7.042,10.791,5.313,7.997,5.654,9.27,3.1])
    train_Y=np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,2.827,3.465,1.65,2.904,2.42,2.94,1.3])
    n_samples=train_X.shape[0]
    X=tf.placeholder(shape=(),dtype=tf.float32, name="x")
    Y=tf.placeholder(shape=(),dtype=tf.float32, name="y")
    
    W=tf.Variable(np.random.randn(),name="weight")
    b=tf.Variable(np.random.randn(),name='bias')
    
    pred=tf.add(tf.multiply(X,W),b)
    
    cost=tf.reduce_sum(tf.pow(pred-Y,2))/(2*n_samples)
    
    optimizer=tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
    
    init = tf.global_variables_initializer()
    
    with tf.Session() as sess:
        sess.run(init)
        for epoch in range(training_epochs):
            for (x,y) in zip(train_X,train_Y):
                sess.run(optimizer, feed_dict={X: x, Y: y})
        tf.saved_model.simple_save(sess, './liner', inputs={"x": X}, outputs={"y": pred})
        writer = tf.summary.FileWriter("./logs", sess.graph)
        writer.close()

  • 相关阅读:
    腾讯ios内部视频,什么垃圾视频
    项目中学习ReactiveCocoa的使用方法
    Mac 裁剪mp3
    AFN使用etag进行网络缓存
    Mac 高效 软件
    presentedViewController 和 presentingViewController 以及 dismissViewControllerAnimated 的使用
    Objective-C: NSFileManager 的使用
    UIButton的imageEdgeInsets 和 titleEdgeInsets
    Objective-C :Category
    Objective-C中的@property
  • 原文地址:https://www.cnblogs.com/mysqlinternal/p/15066743.html
Copyright © 2011-2022 走看看