简体   繁体   English

Tensorflow Session.Run在Android设备上运行时给出空的输出张量,但在Ubuntu上运行时工作正常

[英]Tensorflow Session.Run gives empty Output tensor when run on Android device but works fine when run on Ubuntu

I have a pre trained Tensorflow protobuf that I load from C++ API and build using Bazel. 我有一个经过预训练的Tensorflow原型,可以从C ++ API加载并使用Bazel进行构建。 I get expected output tensors when I run the generated executable on Ubuntu. 在Ubuntu上运行生成的可执行文件时,得到了预期的输出张量。 But when I compile the exact same code for Android using Bazel, I get empty output tensors. 但是,当我使用Bazel编译与Android完全相同的代码时,我得到的输出张量为空。

Code I use to get the output (same code used in both Ubuntu and Android): 我用来获取输出的代码(在Ubuntu和Android中使用的相同代码):

auto statusPred = session->Run(run_options, input, vNames, {}, &answer, &run_metadata);printLog(answer.size());

The answer has size 0 on Android, but has the right expected size when I run the executable, also built using Bazel on UBuntu machine. 答案在Android上的大小为0,但在运行可执行文件时也具有正确的预期大小,该可执行文件也是使用UBuntu计算机上的Bazel构建的。

Am I missing something fundamental here? 我在这里缺少基本的东西吗? Is there a difference between the way computation is done on Ubuntu and Android because of which the output tensor is empty? 由于输出张量为空,因此在Ubuntu和Android上进行计算的方式之间是否有区别?

Fixed it by adding "cwise_op_floor.cc", to file tensorflow/core/kernels/BUILD, under filegroup android_extended_ops_group1. 通过在文件组android_extended_ops_group1下的文件tensorflow / core / kernels / BUILD中添加“ cwise_op_floor.cc”来修复该问题。 I see that the latest version has this Op included under the same filegroup though: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/BUILD#L987 我看到最新版本的Op包含在同一文件组下: https : //github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/BUILD#L987

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 应用程序在模拟器上运行良好,但在真实设备上运行时会出现错误解析包 - Android app running fine on emulator but gives error parsing package when made to run on real device 在Android设备上运行时,FontMetrics不正确。模拟器很好 - FontMetrics not correct when run on android device. Simulator fine 从手机运行时,Android App崩溃,但在模拟器中工作正常 - Android App crashes when run from phone but works fine in emulator 通过设备运行USB调试时,UI会失真,但在AVD上可以正常工作 - My UI gets distorted when I run it through my device(USB debugging) but works fine on my AVD 在设备上运行时发生UnknownHostException - UnknownHostException when run on device Flutter - 发布版本中的屏幕是灰色的,但从 Android Studio 运行时可以正常工作 - Flutter - A screen is grey in release build, but works fine when run from Android Studio 当安卓设备解锁时运行任务 - Run task when android device is unlocked 在Android设备中运行Worklight应用程序时出错 - Error when run Worklight app in android device 在设备上运行时Android和Eclipse的问题 - Problems with Android and Eclipse when Run on Device 首次运行时Unity-Android-App崩溃,但第二次运行正常 - Unity-Android-App Crashes when Run First Time but From Second Time it Works Fine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM