小编Guo*_*uai的帖子

在 macOS 上,“is_always_lock_free”给出“true”,但“is_lock_free()”给出“false”,为什么?

我正在尝试 C++ 原子std::atomic<T>::is_always_lock_freestd::atomic<T>::is_lock_free.

我写了一个简单的结构体A,想知道 的原子版本是否A是无锁的:

#include <iostream>
#include <atomic>

using namespace std;

struct A {
  int x;
  int y;
  int z;
};

int main() {
  atomic<A> b;

  cout << boolalpha;
  cout << "b.is_always_lock_free = " << b.is_always_lock_free << endl;
  cout << "b.is_lock_free = " << b.is_lock_free() << endl;

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

x86-64 Linux上,我用g++ 9.4.0和C++17编译它,输出正常:

b.is_always_lock_free = false
b.is_lock_free = false
Run Code Online (Sandbox Code Playgroud)

然而,我也在我的Mac(ARM64 )上用clang++ 16.0.0编译它,输出很奇怪:

b.is_always_lock_free = true …
Run Code Online (Sandbox Code Playgroud)

c++ macos clang lock-free stdatomic

29
推荐指数
1
解决办法
664
查看次数

调用 TensorFlow Keras 模型时,“training=True”是什么意思?

在 TensorFlow 的官方文档中,它们总是training=True在训练循环中调用 Keras 模型时通过,例如logits = mnist_model(images, training=True).

我试过了help(tf.keras.Model.call),它表明

Help on function call in module tensorflow.python.keras.engine.network:

call(self, inputs, training=None, mask=None)
    Calls the model on new inputs.

    In this case `call` just reapplies
    all ops in the graph to the new inputs
    (e.g. build a new computational graph from the provided inputs).

    Arguments:
        inputs: A tensor or list of tensors.
        training: Boolean or boolean scalar tensor, indicating whether to run
          the `Network` in training mode …
Run Code Online (Sandbox Code Playgroud)

keras tensorflow

8
推荐指数
1
解决办法
7387
查看次数

为什么我不需要MinGW中的-lm标志但是在Linux中我需要明确地使用它?

如果我需要使用数学库,我需要-lm在Linux中使用GCC时添加.但是在Windows上,当我在MinGW-w64中使用GCC时,我没有使用-lm它并且效果很好.

我知道有必要链接的原因libm.但我真的不知道为什么我可以在Windows中省略它?

c c++ linux windows gcc

1
推荐指数
1
解决办法
301
查看次数

标签 统计

c++ ×2

c ×1

clang ×1

gcc ×1

keras ×1

linux ×1

lock-free ×1

macos ×1

stdatomic ×1

tensorflow ×1

windows ×1